﻿using netDxf;
using netDxf.Entities;
using netDxf.Header;
using netDxf.Tables;
using System;
using System.Collections.Generic;

namespace TestDxfDocument

{

    class 
        Class13
    {
        public static void RhombicInsert2(Dictionary<string, Object> data)    //修光刃菱形刀片
        {
            DxfDocument dxf = new DxfDocument();
            dxf.Layers["0"].Lineweight = Lineweight.W25;
            Layer contour = new Layer("contour");//轮廓层
            Layer dimensioning = new Layer("dimensioning");//尺寸层
            Layer refin = new Layer("refin");//基准线/内轮廓/虚线
            Layer center = new Layer("center");//中心线
            Layer textlayer = new Layer("textlayer");//文本层
            Layer hatching = new Layer("hatching");//填充层
            Layer additionalline = new Layer("additionalline");//附加线
            Layer cutting = new Layer("cutting");//切削层
            fun.SetLayer(dxf);


            double tic = Convert.ToDouble(data["ic"]);
            double scale = Convert.ToDouble(data["scale"]); //放大系数

            double offset = 10;
            double textsize = 3.5;

            if (scale == 0 && tic < 9)
            {
                scale = 3.0;
            }
            else if (scale == 0 && tic < 20)
            {
                scale = 2.5;
            }
            else if (scale == 0)
            {
                scale = 2.0;
            }


            /*
            string path = Convert.ToString(data["path"]);
            double pi = Math.PI;
            double scale = 3;
            double s = 4.76* scale;
            double L = 12.9 * scale;
            double M = 0.936 * scale;
            double BS = 1.4 * scale;//修光刃长度
            double EPSR = 80 ;
            double KRINS = 90 ;
            double KCH = 45 ;
            double an = 7;
            double bch = 0.2 * scale;
            double BCH = Math .Sqrt (2)*bch ;
            double AS = 10;//偏的角度
            double l1 = 3.0 * scale;
            double epsr = EPSR;
            double dxc = 0.8;
            double cb = 0;
            double d =12.7 * scale;
            double an_=an*pi/180 ;
            double b = BS;
            double ic = d;
            double d1 = 5.5 * scale;
            //double EPSRN = 75 * (Math.PI / 180);

            double AS_1 = AS * (Math.PI / 180);

            double EPSR_1 = EPSR * (Math.PI / 180);
            double KRINS_1 = KRINS * (Math.PI / 180);

            double An_1 = an  * (Math.PI / 180);
            double KCH_1 = KCH * (Math.PI / 180);
           */


            string path = Convert.ToString(data["path"]);
            double pi = Math.PI;

            double s = Convert.ToDouble(data["s"]) * scale;
            double L = Convert.ToDouble(data["l"]) * scale;
            double M = Convert.ToDouble(data["m"]) * scale;
            double BS = Convert.ToDouble(data["bs"]) * scale;
            double EPSR = Convert.ToDouble(data["epsr"]);
            double KRINS = Convert.ToDouble(data["krins"]);
            double KCH = Convert.ToDouble(data["kch"]);
            double an = Convert.ToDouble(data["an"]);
            double bch = Convert.ToDouble(data["bch"]) * scale;
            double BCH = Math.Sqrt(2) * bch;
            double AS = Convert.ToDouble(data["as"]);
            double l1 = Convert.ToDouble(data["l1"]) * scale;
            double epsr = EPSR;
            double dxc = Convert.ToDouble(data["dxc"]);
            int cb = (int)Convert.ToDecimal(data["cb"]);
            double d = Convert.ToDouble(data["ic"]) * scale;
            double an_ = an * pi / 180;//偏的角度
            double b = BS;//修光刃长度
            double ic = d;
            double d1 = Convert.ToDouble(data["d1"]) * scale;
            //double EPSRN = 75 * (Math.PI / 180);

            double AS_1 = AS * (Math.PI / 180);

            double EPSR_1 = EPSR * (Math.PI / 180);
            double KRINS_1 = KRINS * (Math.PI / 180);

            double An_1 = an * (Math.PI / 180);
            double KCH_1 = KCH * (Math.PI / 180);


            DimensionStyle dimensionStyle = fun.CreateDimStyle();
            dimensionStyle.ArrowSize = textsize;
            dimensionStyle.DimArrow1 = DimensionArrowhead.Closedfilled;
            dimensionStyle.DimArrow2 = DimensionArrowhead.Closedfilled;
            //文本样式
            dimensionStyle.TextHeight = textsize;


            Vector2 p0 = new Vector2(0, 0);
            Vector2 p1 = fun.Polar(p0, ((pi - EPSR_1) / 2) - pi, d / 2 / (Math.Sin((pi - EPSR_1) / 2)));
            Vector2 p1v = fun.Polar(p1, 0, Math.Cos(KCH_1) * BCH);
            Vector2 p1p = fun.Polar(p1, pi - EPSR_1, Math.Cos(KCH_1) * BCH);
            Vector2 p2 = fun.Polar(p1, pi - EPSR_1, L);
            Vector2 p2v = fun.Polar(p2, 0, Math.Cos(KCH_1) * BCH);
            Vector2 p2p = fun.Polar(p2, -EPSR_1, Math.Cos(KCH_1) * BCH);
            Vector2 p3 = fun.Polar(p2, 0, L);
            Vector2 p3v = fun.Polar(p3, pi, Math.Cos(KCH_1) * BCH);
            Vector2 p3p = fun.Polar(p3, -EPSR_1, Math.Cos(KCH_1) * BCH);
            Vector2 p7 = fun.Polar(p0, pi / -2, d / 2);

            Vector2 p4 = fun.Polar(p3, -EPSR_1, L);
            Vector2 p4v = fun.Polar(p4, pi - EPSR_1, Math.Cos(KCH_1) * BCH);
            Vector2 p4p = fun.Polar(p4, pi, Math.Cos(KCH_1) * BCH);
            Vector2 p5 = fun.Polar(p4, pi - EPSR_1, l1);
            System.Diagnostics.Debug.WriteLine((pi - EPSR_1) * 180 / pi);

            Vector2 p6 = fun.Polar(p4, pi, l1);
            Vector2 v8 = fun.Polar(p7, pi / -2 + AS_1, M);
            //Vector2 v9 = new Vector2 (d/2-bch-b ,p7.Y  );
            Vector2 v9 = fun.Polar(v8, (AS_1), (p4.X - b - bch) * Math.Cos(AS_1));
            Vector2 v10 = fun.Polar(v9, AS_1, b);
            Vector2 v11 = fun.Polar(v10, KCH_1 + AS_1, bch);


            Vector2 p8 = fun.Polar(p0, pi + AS_1, d / 2 + 2);
            Vector2 p9 = fun.Polar(p0, 0 + AS_1, d / 2 + 2);
            Vector2 p10 = fun.Polar(p0, pi / 2 + AS_1, d / 2 + 2);
            Vector2 p11 = fun.Polar(p0, pi / -2 + AS_1, d / 2 + 2);

            Vector2 p20 = fun.Polar(p0, 0, (ic * 4));
            Vector2 p21 = fun.Polar(p20, (pi / 2), (ic / 2));



            Vector2 v1 = fun.Polar(p0, 2 * pi - (epsr * pi / 180 / 2), (ic / 2) / Math.Sin(EPSR_1 / 2) * dxc);
            Vector2 v2 = fun.Polar(p0, -90 * pi / 180 - (epsr * pi / 180 / 2), (ic / 2) / Math.Cos(EPSR_1 / 2) * dxc); ;
            Vector2 v3 = fun.Polar(p0, pi / 2 + (epsr * pi / 180 / 2), (ic / 2) / Math.Sin(EPSR_1 / 2) * dxc);
            Vector2 v4 = fun.Polar(p0, 90 * pi / 180 - epsr * pi / 180 / 2, (ic / 2) / Math.Cos(EPSR_1 / 2) * dxc);

            //Line line100 = new Line(v8,fun .Polar (p0,45*pi/180,20));
            //dxf.AddEntity(line100 );
            //标注
            Vector2 p27 = fun.Polar(p21, pi / -2, ic / 2);
            Vector2 p28 = fun.Polar(p21, pi, s);
            Vector2 p29 = fun.Polar(p27, pi - an, 1.5 * s);
            Vector2 p30 = fun.Polar(p4p, pi, b);
            Vector2 p31 = fun.Polar(p20, pi / -2, d / 2);
            if (cb == 1 || cb == 2)
            {

                LwPolyline Line01 = new LwPolyline();
                Line01.Vertexes.Add(new LwPolylineVertex(v1));
                Line01.Vertexes.Add(new LwPolylineVertex(v2));
                Line01.Vertexes.Add(new LwPolylineVertex(v3));
                Line01.Vertexes.Add(new LwPolylineVertex(v4));
                Line01.Vertexes.Add(new LwPolylineVertex(v1));
                Line01.Lineweight = Lineweight.W35;
                Line01.Layer = additionalline;
                dxf.AddEntity(Line01);

            }


            LwPolyline poly1 = new LwPolyline();
            poly1.Vertexes.Add(new LwPolylineVertex(p1v));
            poly1.Vertexes[0].Bulge = Math.Tan((KCH_1) / -4);
            poly1.Vertexes.Add(new LwPolylineVertex(p1p));
            poly1.Vertexes.Add(new LwPolylineVertex(p2p));
            poly1.Vertexes[2].Bulge = Math.Tan((KCH_1) / -4);
            poly1.Vertexes.Add(new LwPolylineVertex(p2v));
            poly1.Vertexes.Add(new LwPolylineVertex(p3v));
            poly1.Vertexes[4].Bulge = Math.Tan((KCH_1) / -4);
            poly1.Vertexes.Add(new LwPolylineVertex(p3p));
            poly1.Vertexes.Add(new LwPolylineVertex(p5));
            poly1.Vertexes.Add(new LwPolylineVertex(v11));
            poly1.Vertexes.Add(new LwPolylineVertex(v10));
            poly1.Vertexes.Add(new LwPolylineVertex(v9));
            poly1.Vertexes.Add(new LwPolylineVertex(p6));
            poly1.Vertexes.Add(new LwPolylineVertex(p1v));


            fun.PolyFill(dxf, poly1, 0.5, contour);

            Circle circle1 = new Circle(new Vector3(0, 0, 0), d / 2);//圆
            circle1.Linetype = Linetype.DashDot;
            circle1.Lineweight = netDxf.Lineweight.W35;
            circle1.Layer = refin;
            dxf.AddEntity(circle1);

            LwPolyline poly2 = new LwPolyline();
            poly2.Vertexes.Add(new LwPolylineVertex(p5));
            poly2.Vertexes.Add(new LwPolylineVertex(v11));
            poly2.Vertexes.Add(new LwPolylineVertex(v10));
            poly2.Vertexes.Add(new LwPolylineVertex(v9));
            poly2.Vertexes.Add(new LwPolylineVertex(p6));
            poly2.Vertexes.Add(new LwPolylineVertex(p5));
            fun.PolyFill(dxf, poly2, 0.5, contour);
            String[] htype1 = new String[100];
            Line[] hline1 = new Line[100];
            Arc[] harc1 = new Arc[100];
            int hnumst1 = poly2.Explode().Count;  //记录爆炸后，线段有多少
            for (int i = 0; i < hnumst1; i++)
            {
                htype1[i] = poly2.Explode()[i].Type.ToString();    //将所有元素的类型记录成一个数组
                if (htype1[i] == "Line")
                {
                    hline1[i] = (Line)poly2.Explode()[i];
                }
                if (htype1[i] == "Arc")
                {
                    harc1[i] = (Arc)poly2.Explode()[i];
                }
            }
            fun.hatchsub1(dxf, htype1, hnumst1, 45, 1, hline1, harc1, hatching);

            String[] htype2 = new String[100];
            Line[] hline2 = new Line[100];
            Arc[] harc2 = new Arc[100];
            int hnumst2 = poly2.Explode().Count;  //记录爆炸后，线段有多少
            for (int i = 0; i < hnumst1; i++)
            {
                htype2[i] = poly2.Explode()[i].Type.ToString();    //将所有元素的类型记录成一个数组
                if (htype2[i] == "Line")
                {
                    hline2[i] = (Line)poly2.Explode()[i];
                }
                if (htype2[i] == "Arc")
                {
                    harc2[i] = (Arc)poly2.Explode()[i];
                }
            }
            fun.hatchsub1(dxf, htype2, hnumst2, 135, 1, hline2, harc2, hatching);



            Line line1 = new Line(p8, p9);
            Line line2 = new Line(p10, p11);
            line1.Linetype = Linetype.Dashed;
            line1.Lineweight = netDxf.Lineweight.W25;
            line1.Layer = center;
            dxf.AddEntity(line1);
            line2.Linetype = Linetype.Dashed;
            line2.Lineweight = netDxf.Lineweight.W25;
            line2.Layer = center;
            dxf.AddEntity(line2);

            insert.inserthole(dxf, p0, v2, v3, p20, p21, scale, data);




            //标注
            fun.dimrot1(dxf, p1, p2, 100, offset, 2, textsize, 1.6 * scale, 0.9, "  l=" + L/scale , "", "");
            fun.dimrot1(dxf, p2, p3, 10, offset, 2,  textsize, 1.6 * scale, 0.9, "  d=" + d / scale, "", "");
            fun.dimrot1(dxf, p5, p4, -80, offset * 2 , 2, textsize, 1.6 * scale, 0.9, "  l1=" + l1 / scale, "", "");
            fun.dimrot1(dxf, p4p, p4, -170, offset, 2, textsize, 1.6 * scale, 0.9, "  bch=" + bch / scale, "", "");
            fun.dimrot1(dxf, p30, p4p, -170, offset*2 , 2, textsize, 1.6 * scale, 0.9, "  b=" + b / scale, "", "");
            fun.dimrot1(dxf, p7, p4, 100, offset*5.5 , 2, textsize, 1.6 * scale, 0.9, "  m=" + M / scale, "", "");
            fun.dimrot1(dxf, p31, fun.Polar(p31, pi, s), 180, offset, 2, textsize, 1.6 * scale, 0.9, "  s=" + s / scale, "", "");
            fun.jdbz2(dxf, new Line(p2, fun.Polar(p2, pi - EPSR_1, L)), new Line(p2, fun.Polar(p2, pi, L)), offset, textsize, 1.6 * scale, 0.9, "epsr=" + epsr , "°", "");
            fun.jdbz2(dxf, new Line(v10, fun.Polar(v10, an_ * pi / 180, L)), new Line(v11, p3p), offset * 3.5, textsize, 1.6 * scale, 0.9, "90=", "", "");
            fun.jdbz2(dxf, new Line(p31, fun.Polar(p31, pi - An_1, L / 2)), new Line(p31, fun.Polar(p31, pi, L / 2)), offset * 3, textsize, 1.6 * scale, 0.9, "an=" + an, "°", "");
            fun.jdbz2(dxf, new Line(v10, fun.Polar(v10, an_ * pi / 180, 0.1)), new Line(v10, v11), offset   , textsize, 1.6 * scale, 0.9, "kch=" + KCH , "", "");



            fun.SetLayer(dxf);
            fun.SetByLayer(dxf);

            dxf.DrawingVariables.AcadVer = DxfVersion.AutoCad2007;
            dxf.Save(path);
            


        }

        public static void _Rhombic80class13(Dictionary<string, Object> data)    //带固定孔的80 菱形铣削刀片
        {
            DxfDocument dxf = new DxfDocument();
            dxf.Layers["0"].Lineweight = Lineweight.W25;
            Layer contour = new Layer("contour");//轮廓层
            Layer dimensioning = new Layer("dimensioning");//尺寸层
            Layer refin = new Layer("refin");//基准线/内轮廓/虚线
            Layer center = new Layer("center");//中心线
            Layer textlayer = new Layer("textlayer");//文本层
            Layer hatching = new Layer("hatching");//填充层
            Layer additionalline = new Layer("additionalline");//附加线
            Layer cutting = new Layer("cutting");//切削层
            fun.SetLayer(dxf);

            /*
            double tic = Convert.ToDouble(data["ic"]);
            double scale = Convert.ToDouble(data["scale"]); //放大系数
            if (scale == 0 && tic < 9)
            {
                scale = 3.0;
            }
            else if (scale == 0 && tic < 20)
            {
                scale = 2.5;
            }
            else if (scale == 0)
            {
                scale = 2.0;
            }
            */
            /*
            string path = Convert.ToString(data["path"]);
            double pi = Math.PI;

            double IC = Convert.ToDouble(data["ic"]);
            double S = Convert.ToDouble(data["s"]);
            double L = IC;
            double M = Convert.ToDouble(data["m"]);
            double BS = Convert.ToDouble(data["bs"]);
            double EPSR = Convert.ToDouble(data["epsr"]);
            double KRINS = Convert.ToDouble(data["krins"]);
            double KCH = Convert.ToDouble(data["kch"]);
            double AN = Convert.ToDouble(data["an"]);
            double BCH = Convert.ToDouble(data["bch"]);
            double AS = Convert.ToDouble(data["as"]);
            */
            string path = Convert.ToString(data["path"]);
            double pi = Math.PI;

            double IC = 12.7;
            double S = 4.76;
            double L = IC;
            double M = 0.8;
            double BS = 1.4;
            double EPSR = 90;
            double KRINS = 90;
            double KCH = 45;
            double AN = 11;
            double BCH = 1;
            double AS = 11;



            //double EPSRN = 75 * (Math.PI / 180);

            double AS_1 = AS * (Math.PI / 180);

            double EPSR_1 = EPSR * (Math.PI / 180);
            double KRINS_1 = KRINS * (Math.PI / 180);

            double An_1 = AN * (Math.PI / 180);
            double KCH_1 = KCH * (Math.PI / 180);




            DimensionStyle dimensionStyle = fun.CreateDimStyle();
            dimensionStyle.ArrowSize = 0.2;
            dimensionStyle.DimArrow1 = DimensionArrowhead.Closedfilled;
            dimensionStyle.DimArrow2 = DimensionArrowhead.Closedfilled;
            //文本样式
            dimensionStyle.TextHeight = 0.3;
            double offset = 3;

            if (KRINS == 75 && AN == 0)
            {


                Vector2 v1 = new Vector2(0, 0);
                Vector2 v2 = new Vector2(v1.X - (BS * Math.Cos(EPSR_1 - KRINS_1)), v1.Y + (BS * Math.Sin(EPSR_1 - KRINS_1)));
                Vector2 v3 = new Vector2(v2.X - (BCH * Math.Sin(KCH_1)), v2.Y + BCH * Math.Cos(KCH_1));
                Vector2 v4 = new Vector2(v3.X - (BS * Math.Sin(EPSR_1 - KRINS_1)), v3.Y + (BS * Math.Cos(EPSR_1 - KRINS_1)));
                double length1 = fun.CalDistance(v1, v4);

                Vector2[] Line1 = { v1, v2 };
                fun.drawBLine(dxf, Line1, 0.3, contour);
                Vector2[] Line2 = { v2, v3 };
                fun.drawBLine(dxf, Line2, 0.3, contour);
                Vector2[] Line3 = { v3, v4 };
                fun.drawBLine(dxf, Line3, 0.3, contour);

                Vector2 v18 = new Vector2(v4.X, v1.Y + L / 2);
                Vector2 v19 = new Vector2(v18.X + L, v18.Y);
                Vector2 v20 = new Vector2(v4.X + L / 2, v1.X + L);
                Vector2 v21 = new Vector2(v20.X, v20.Y - L);
                Vector2 v22 = new Vector2(v4.X, v1.Y + L);
                Vector2 v23 = new Vector2(v4.X + L, v1.Y);



                Line Line4 = fun.mirrorline(new Line(v1, v2), v18, v19);
                Vector2[] lsl1 = { new Vector2(Line4.StartPoint.X, Line4.StartPoint.Y), new Vector2(Line4.EndPoint.X, Line4.EndPoint.Y) };
                fun.drawBLine(dxf, lsl1, 0.3, contour);
                Line Line5 = fun.mirrorline(new Line(v2, v3), v18, v19);
                Vector2[] lsl2 = { new Vector2(Line5.StartPoint.X, Line5.StartPoint.Y), new Vector2(Line5.EndPoint.X, Line5.EndPoint.Y) };
                fun.drawBLine(dxf, lsl2, 0.3, contour);
                Line Line6 = fun.mirrorline(new Line(v4, v3), v18, v19);
                Vector2[] lsl3 = { new Vector2(Line6.StartPoint.X, Line6.StartPoint.Y), new Vector2(Line6.EndPoint.X, Line6.EndPoint.Y) };
                fun.drawBLine(dxf, lsl3, 0.3, contour);


                Line Line7 = fun.mirrorline(new Line(v1, v2), v22, v23);
                Vector2[] lsl4 = { new Vector2(Line7.StartPoint.X, Line7.StartPoint.Y), new Vector2(Line7.EndPoint.X, Line7.EndPoint.Y) };
                fun.drawBLine(dxf, lsl4, 0.3, contour);
                Line Line8 = fun.mirrorline(new Line(v3, v2), v22, v23);
                Vector2[] lsl5 = { new Vector2(Line8.StartPoint.X, Line8.StartPoint.Y), new Vector2(Line8.EndPoint.X, Line8.EndPoint.Y) };
                fun.drawBLine(dxf, lsl5, 0.3, contour);
                Line Line9 = fun.mirrorline(new Line(v3, v4), v22, v23);
                Vector2[] lsl6 = { new Vector2(Line9.StartPoint.X, Line9.StartPoint.Y), new Vector2(Line9.EndPoint.X, Line9.EndPoint.Y) };
                fun.drawBLine(dxf, lsl6, 0.3, contour);

                Line Line10 = fun.mirrorline(new Line(v1, v2), v20, v21);
                Vector2[] lsl7 = { new Vector2(Line10.StartPoint.X, Line10.StartPoint.Y), new Vector2(Line10.EndPoint.X, Line10.EndPoint.Y) };
                fun.drawBLine(dxf, lsl7, 0.3, contour);
                Line Line11 = fun.mirrorline(new Line(v3, v2), v20, v21);
                Vector2[] lsl8 = { new Vector2(Line11.StartPoint.X, Line11.StartPoint.Y), new Vector2(Line11.EndPoint.X, Line11.EndPoint.Y) };
                fun.drawBLine(dxf, lsl8, 0.3, contour);
                Line Line12 = fun.mirrorline(new Line(v3, v4), v20, v21);
                Vector2[] lsL9 = { new Vector2(Line12.StartPoint.X, Line12.StartPoint.Y), new Vector2(Line12.EndPoint.X, Line12.EndPoint.Y) };
                fun.drawBLine(dxf, lsL9, 0.3, contour);

                Vector2 v5 = new Vector2(Line6.StartPoint.X, Line6.StartPoint.Y);
                Vector2[] Line13 = { v4, v5 };
                fun.drawBLine(dxf, Line13, 0.3, contour);

                Vector2 v6 = new Vector2(Line6.EndPoint.X, Line6.EndPoint.Y);
                Vector2 v7 = new Vector2(Line4.EndPoint.X, Line4.EndPoint.Y);

                Vector2 v8 = new Vector2(Line4.StartPoint.X, Line4.StartPoint.Y);
                Vector2 v9 = new Vector2(Line9.EndPoint.X, Line9.EndPoint.Y);

                Vector2 v10 = new Vector2(Line9.StartPoint.X, Line9.StartPoint.X);
                Vector2 v11 = new Vector2(Line7.StartPoint.X, Line7.StartPoint.Y);
                Vector2 v14 = new Vector2(Line12.StartPoint.X, Line12.StartPoint.Y);
                Vector2 v15 = new Vector2(Line10.EndPoint.X, Line10.EndPoint.Y);

                Vector2[] Line14 = { v8, v9 };
                fun.drawBLine(dxf, Line14, 0.3, contour);

                Vector2 v12 = new Vector2(Line7.StartPoint.X, Line7.StartPoint.Y);
                Vector2 v13 = new Vector2(Line12.EndPoint.X, Line12.EndPoint.Y);
                Vector2[] Line15 = { v13, v12 };
                fun.drawBLine(dxf, Line15, 0.3, contour);

                Vector2 v16 = new Vector2(Line10.StartPoint.X, Line10.StartPoint.Y);
                Vector2[] Line16 = { v1, v16 };
                fun.drawBLine(dxf, Line16, 0.3, contour);


                Vector2 v17 = new Vector2(v21.X, v21.Y + L / 2);

                Circle circle00 = new Circle(v17, IC / 2);
                circle00.Layer = center;
                circle00.Lineweight = Lineweight.W50;
                circle00.Linetype = Linetype.DashDot;
                dxf.AddEntity(circle00);


                Vector2 v24 = new Vector2(v23.X + L, v1.Y);
                Vector2 v25 = new Vector2(v24.X, v2.Y);
                Vector2 v26 = new Vector2(v24.X, v3.Y);
                Vector2 v27 = new Vector2(v24.X, v4.Y);
                Vector2 v28 = new Vector2(v24.X, v5.Y);
                Vector2 v29 = new Vector2(v24.X, v6.Y);
                Vector2 v30 = new Vector2(v24.X, v7.Y);
                Vector2 v31 = new Vector2(v24.X, v8.Y);
                Vector2 v32 = new Vector2(v31.X + S, v31.Y);
                Vector2 v33 = new Vector2(v32.X, v30.Y);
                Vector2 v34 = new Vector2(v32.X, v29.Y);
                Vector2 v35 = new Vector2(v32.X, v28.Y);
                Vector2 v36 = new Vector2(v32.X, v27.Y);
                Vector2 v37 = new Vector2(v32.X, v26.Y);
                Vector2 v38 = new Vector2(v32.X, v25.Y);
                Vector2 v39 = new Vector2(v32.X, v24.Y);

                Vector2 v40 = new Vector2(v2.X, v1.Y);
                Vector2 v41 = new Vector2(v2.X + v2.Y / Math.Tan(EPSR_1 / 2), v1.Y);

                Vector2 v42 = new Vector2(v15.X + 1.16, v15.Y + 0.3);
                Vector2 v43 = new Vector2(v15.X + 6.09, v15.Y + 4.62);
                Vector2 v44 = new Vector2(v16.X + 1.99, v16.Y);
                Vector2 v45 = new Vector2(v44.X - 0.95, v44.Y - 3.98);



                LwPolyline poly1 = new LwPolyline();
                poly1.Vertexes.Add(new LwPolylineVertex(v24));
                poly1.Vertexes.Add(new LwPolylineVertex(v31));
                poly1.Vertexes.Add(new LwPolylineVertex(v32));
                poly1.Vertexes.Add(new LwPolylineVertex(v39));
                poly1.Vertexes.Add(new LwPolylineVertex(v24));

                poly1.IsClosed = true;
                fun.PolyFill(dxf, poly1, 0.3, contour);


                Vector2[] line18 = { v26, v37 };
                fun.drawBLine(dxf, line18, 0.3, contour);

                Vector2[] line20 = { v29, v34 };
                fun.drawBLine(dxf, line20, 0.3, contour);

                Vector2[] line22 = { v31, v32 };
                fun.drawBLine(dxf, line22, 0.3, contour);
                Vector2[] Line17 = { v25, v38 };
                fun.drawBLine(dxf, Line17, 0.3, contour);
                Vector2[] line19 = { v28, v35 };
                fun.drawBLine(dxf, line19, 0.3, contour);
                Vector2[] line21 = { v30, v33 };
                fun.drawBLine(dxf, line21, 0.3, contour);
                Vector2[] line23 = { v27, v36 };
                fun.drawBLine(dxf, line23, 0.3, contour);

                LinearDimension dim9 = new LinearDimension(new Line(v3, v2), offset, 134, dimensionStyle);
                dim9.UserText = "≈1";
                dxf.AddEntity(dim9);
                Angular2LineDimension angdim2 = new Angular2LineDimension(new Line(v41, v40), new Line(v41, v3), offset + 2, dimensionStyle);
                angdim2.UserText = "45°";
                dxf.AddEntity(angdim2);
                LinearDimension dim7 = new LinearDimension(new Line(v15, v16), offset, 165, dimensionStyle);
                dim7.UserText = "bs";
                dxf.AddEntity(dim7);
                LinearDimension dim8 = new LinearDimension(new Line(v13, v14), offset, 260, dimensionStyle);
                dim8.UserText = "bs";
                dxf.AddEntity(dim8);
                LinearDimension dim4 = new LinearDimension(new Line(v19, v13), offset, -19, dimensionStyle);
                dim4.UserText = "m";
                dxf.AddEntity(dim4);
                Angular2LineDimension angdim5 = new Angular2LineDimension(new Line(v13, v14), (new Line(v9, v8)), offset + 20, dimensionStyle);
                angdim5.UserText = "φ";
                dxf.AddEntity(angdim5);
                Angular2LineDimension angdim4 = new Angular2LineDimension(new Line(v44, v1), (new Line(v44, v45)), offset + 2, dimensionStyle);
                angdim4.UserText = "xr＝75°";
                dxf.AddEntity(angdim4);

                Angular2LineDimension angdim3 = new Angular2LineDimension((new Line(v42, v12)), new Line(v42, v43), offset + 2, dimensionStyle);
                angdim3.UserText = "xr＝75°";
                dxf.AddEntity(angdim3);


                //线段尺寸标注
                //尺寸1
                LinearDimension dim1 = new LinearDimension(new Line(v5, v12), offset + 2, 360, dimensionStyle);
                dim1.UserText = "l";
                dxf.AddEntity(dim1);

                LinearDimension dim2 = new LinearDimension(new Line(v1, v8), offset + 2, 90, dimensionStyle);
                dim2.UserText = "l";
                dxf.AddEntity(dim2);
                LinearDimension dim3 = new LinearDimension(new Line(v18, v19), offset - 3, 360, dimensionStyle);
                dim3.UserText = "d";
                dxf.AddEntity(dim3);

                LinearDimension dim5 = new LinearDimension(new Line(v21, v16), offset, 110, dimensionStyle);
                dim5.UserText = "m";
                dxf.AddEntity(dim5);
                LinearDimension dim6 = new LinearDimension(new Line(v24, v39), offset + 2, 180, dimensionStyle);
                dim6.UserText = "S";
                dxf.AddEntity(dim6);



                Angular2LineDimension angdim1 = new Angular2LineDimension(new Line(v23, v19), new Line(v23, v21), offset + 3, dimensionStyle);
                angdim1.UserText = "εr";
                dxf.AddEntity(angdim1);





                Angular2LineDimension angdim6 = new Angular2LineDimension(new Line(v16, v15), (new Line(v4, v5)), offset + 25, dimensionStyle);
                angdim6.UserText = "φ";
                dxf.AddEntity(angdim6);



            }



            if (KRINS == 45 && AN == 0)
            {

                Vector2 v1 = new Vector2(0, 0);
                Vector2 v2 = new Vector2(v1.X - (BS * Math.Cos(EPSR_1 - KRINS_1)), v1.Y + (BS * Math.Sin(EPSR_1 - KRINS_1)));
                Vector2 v3 = new Vector2(v2.X - (BCH * Math.Sin(KCH_1)), v2.Y + BCH * Math.Cos(KCH_1));
                Vector2 v4 = new Vector2(v3.X - (BS * Math.Sin(EPSR_1 - KRINS_1)), v3.Y + (BS * Math.Cos(EPSR_1 - KRINS_1)));
                double length1 = fun.CalDistance(v1, v4);






                Vector2 v18 = new Vector2(v4.X, v1.Y + L / 2);
                Vector2 v19 = new Vector2(v18.X + L, v18.Y);
                Vector2 v20 = new Vector2(v4.X + L / 2, v1.X + L);
                Vector2 v21 = new Vector2(v20.X, v20.Y - L);
                Vector2 v22 = new Vector2(v4.X, v1.Y + L);
                Vector2 v23 = new Vector2(v4.X + L, v1.Y);



                Line Line4 = fun.mirrorline(new Line(v1, v2), v18, v19);
                Vector2[] lsl1 = { new Vector2(Line4.StartPoint.X, Line4.StartPoint.Y), new Vector2(Line4.EndPoint.X, Line4.EndPoint.Y) };
                ;
                Line Line5 = fun.mirrorline(new Line(v2, v3), v18, v19);
                Vector2[] lsl2 = { new Vector2(Line5.StartPoint.X, Line5.StartPoint.Y), new Vector2(Line5.EndPoint.X, Line5.EndPoint.Y) };
                ;
                Line Line6 = fun.mirrorline(new Line(v4, v3), v18, v19);
                Vector2[] lsl3 = { new Vector2(Line6.StartPoint.X, Line6.StartPoint.Y), new Vector2(Line6.EndPoint.X, Line6.EndPoint.Y) };



                Line Line7 = fun.mirrorline(new Line(v1, v2), v22, v23);
                Vector2[] lsl4 = { new Vector2(Line7.StartPoint.X, Line7.StartPoint.Y), new Vector2(Line7.EndPoint.X, Line7.EndPoint.Y) };

                Line Line8 = fun.mirrorline(new Line(v3, v2), v22, v23);
                Vector2[] lsl5 = { new Vector2(Line8.StartPoint.X, Line8.StartPoint.Y), new Vector2(Line8.EndPoint.X, Line8.EndPoint.Y) };
                ;
                Line Line9 = fun.mirrorline(new Line(v3, v4), v22, v23);
                Vector2[] lsl6 = { new Vector2(Line9.StartPoint.X, Line9.StartPoint.Y), new Vector2(Line9.EndPoint.X, Line9.EndPoint.Y) };


                Line Line10 = fun.mirrorline(new Line(v1, v2), v20, v21);
                Vector2[] lsl7 = { new Vector2(Line10.StartPoint.X, Line10.StartPoint.Y), new Vector2(Line10.EndPoint.X, Line10.EndPoint.Y) };

                Line Line11 = fun.mirrorline(new Line(v3, v2), v20, v21);
                Vector2[] lsl8 = { new Vector2(Line11.StartPoint.X, Line11.StartPoint.Y), new Vector2(Line11.EndPoint.X, Line11.EndPoint.Y) };

                Line Line12 = fun.mirrorline(new Line(v3, v4), v20, v21);
                Vector2[] lsL9 = { new Vector2(Line12.StartPoint.X, Line12.StartPoint.Y), new Vector2(Line12.EndPoint.X, Line12.EndPoint.Y) };


                Vector2 v5 = new Vector2(Line6.StartPoint.X, Line6.StartPoint.Y);
                Vector2[] Line13 = { v4, v5 };
                fun.drawBLine(dxf, Line13, 0.3, contour);

                Vector2 v6 = new Vector2(Line6.EndPoint.X, Line6.EndPoint.Y);
                Vector2 v7 = new Vector2(Line4.EndPoint.X, Line4.EndPoint.Y);

                Vector2 v8 = new Vector2(Line4.StartPoint.X, Line4.StartPoint.Y);
                Vector2 v9 = new Vector2(Line9.EndPoint.X, Line9.EndPoint.Y);

                Vector2 v10 = new Vector2(Line9.StartPoint.X, Line9.StartPoint.X);
                Vector2 v11 = new Vector2(Line7.StartPoint.X, Line7.StartPoint.Y);
                Vector2 v14 = new Vector2(Line12.StartPoint.X, Line12.StartPoint.Y);
                Vector2 v15 = new Vector2(Line10.EndPoint.X, Line10.EndPoint.Y);

                Vector2[] Line14 = { v8, v9 };
                fun.drawBLine(dxf, Line14, 0.3, contour);

                Vector2 v12 = new Vector2(Line7.StartPoint.X, Line7.StartPoint.Y);
                Vector2 v13 = new Vector2(Line12.EndPoint.X, Line12.EndPoint.Y);
                Vector2[] Line15 = { v13, v12 };
                fun.drawBLine(dxf, Line15, 0.3, contour);

                Vector2 v16 = new Vector2(Line10.StartPoint.X, Line10.StartPoint.Y);
                Vector2[] Line16 = { v1, v16 };
                fun.drawBLine(dxf, Line16, 0.3, contour);



                Vector2 v17 = new Vector2(v21.X, v21.Y + L / 2);


                Vector2[] line24 = { v5, v8 };
                fun.drawBLine(dxf, line24, 0.3, contour);
                Vector2[] line25 = { v9, v12 };
                fun.drawBLine(dxf, line25, 0.3, contour);
                Vector2[] line26 = { v13, v16 };
                fun.drawBLine(dxf, line26, 0.3, contour);
                Vector2[] line27 = { v4, v1 };
                fun.drawBLine(dxf, line27, 0.3, contour);

                Circle circle00 = new Circle(v17, IC / 2);
                circle00.Layer = center;
                circle00.Lineweight = Lineweight.W50;
                circle00.Linetype = Linetype.DashDot;
                dxf.AddEntity(circle00);


                Vector2 v24 = new Vector2(v23.X + L, v1.Y);
                Vector2 v25 = new Vector2(v24.X, v2.Y);
                Vector2 v26 = new Vector2(v24.X, v3.Y);
                Vector2 v27 = new Vector2(v24.X, v4.Y);
                Vector2 v28 = new Vector2(v24.X, v5.Y);
                Vector2 v29 = new Vector2(v24.X, v6.Y);
                Vector2 v30 = new Vector2(v24.X, v7.Y);
                Vector2 v31 = new Vector2(v24.X, v8.Y);
                Vector2 v32 = new Vector2(v31.X + S, v31.Y);
                Vector2 v33 = new Vector2(v32.X, v30.Y);
                Vector2 v34 = new Vector2(v32.X, v29.Y);
                Vector2 v35 = new Vector2(v32.X, v28.Y);
                Vector2 v36 = new Vector2(v32.X, v27.Y);
                Vector2 v37 = new Vector2(v32.X, v26.Y);
                Vector2 v38 = new Vector2(v32.X, v25.Y);
                Vector2 v39 = new Vector2(v32.X, v24.Y);

                Vector2 v40 = new Vector2(v2.X, v1.Y);
                Vector2 v41 = new Vector2(v2.X + v2.Y / Math.Tan(EPSR_1 / 2), v1.Y);

                Vector2 v42 = new Vector2(v15.X + 1.16, v15.Y + 0.3);
                Vector2 v43 = new Vector2(v15.X + 6.09, v15.Y + 4.62);
                Vector2 v44 = new Vector2(v16.X + 1.99, v16.Y);
                Vector2 v45 = new Vector2(v44.X - 0.95, v44.Y - 3.98);



                LwPolyline poly1 = new LwPolyline();
                poly1.Vertexes.Add(new LwPolylineVertex(v24));
                poly1.Vertexes.Add(new LwPolylineVertex(v31));
                poly1.Vertexes.Add(new LwPolylineVertex(v32));
                poly1.Vertexes.Add(new LwPolylineVertex(v39));
                poly1.Vertexes.Add(new LwPolylineVertex(v24));

                poly1.IsClosed = true;
                fun.PolyFill(dxf, poly1, 0.3, contour);

                Vector2[] line18 = { v26, v37 };
                fun.drawBLine(dxf, line18, 0.3, contour);

                Vector2[] line20 = { v29, v34 };
                fun.drawBLine(dxf, line20, 0.3, contour);



                Angular2LineDimension angdim3 = new Angular2LineDimension((new Line(v42, v12)), new Line(v42, v43), offset + 2, dimensionStyle);
                angdim3.UserText = "xr＝45°";
                dxf.AddEntity(angdim3);


                //线段尺寸标注
                //尺寸1
                LinearDimension dim1 = new LinearDimension(new Line(v5, v12), offset + 2, 360, dimensionStyle);
                dim1.UserText = "l";
                dxf.AddEntity(dim1);

                LinearDimension dim2 = new LinearDimension(new Line(v1, v8), offset + 2, 90, dimensionStyle);
                dim2.UserText = "l";
                dxf.AddEntity(dim2);
                LinearDimension dim3 = new LinearDimension(new Line(v18, v19), offset - 3, 360, dimensionStyle);
                dim3.UserText = "d";
                dxf.AddEntity(dim3);

                LinearDimension dim5 = new LinearDimension(new Line(v21, v16), offset, 110, dimensionStyle);
                dim5.UserText = "m";
                dxf.AddEntity(dim5);
                LinearDimension dim6 = new LinearDimension(new Line(v24, v39), offset + 2, 180, dimensionStyle);
                dim6.UserText = "S";
                dxf.AddEntity(dim6);



                Angular2LineDimension angdim1 = new Angular2LineDimension(new Line(v23, v19), new Line(v23, v21), offset + 3, dimensionStyle);
                angdim1.UserText = "εr";
                dxf.AddEntity(angdim1);





                Angular2LineDimension angdim6 = new Angular2LineDimension(new Line(v16, v15), (new Line(v4, v5)), offset + 25, dimensionStyle);
                angdim6.UserText = "φ";
                dxf.AddEntity(angdim6);


            }

            if (KRINS != 0 && AN == 11)
            {
                Vector2 v1 = new Vector2(0, 0);
                Vector2 v2 = new Vector2(v1.X - (BS * Math.Cos(EPSR_1 - KRINS_1)), v1.Y + (BS * Math.Sin(EPSR_1 - KRINS_1)));
                Vector2 v3 = new Vector2(v2.X - (BCH * Math.Sin(KCH_1)), v2.Y + BCH * Math.Cos(KCH_1));

                Vector2[] Line1 = { v1, v2 };
                fun.drawBLine(dxf, Line1, 0.3, contour);

                Vector2[] Line2 = { v3, v2 };
                fun.drawBLine(dxf, Line2, 0.3, contour);

                Vector2 v14 = new Vector2(v3.X, v1.Y + L / 2);
                Vector2 v15 = new Vector2(v14.X + L, v14.Y);
                Vector2 v16 = new Vector2(v14.X + L / 2, v1.Y + L);
                Vector2 v17 = new Vector2(v16.X, v16.Y - L);
                Vector2 v13 = new Vector2(v14.X + L / 2, v14.Y);
                Vector2 v18 = new Vector2(v3.X, v1.Y + L);
                Vector2 v19 = new Vector2(v3.X + L, v1.Y);


                Line line3 = fun.mirrorline(new Line(v1, v2), v14, v15);
                Vector2[] lsline1 = { new Vector2(line3.StartPoint.X, line3.StartPoint.Y), new Vector2(line3.EndPoint.X, line3.EndPoint.Y) };
                fun.drawBLine(dxf, lsline1, 0.3, contour);
                Line line4 = fun.mirrorline(new Line(v2, v3), v14, v15);
                Vector2[] lsline2 = { new Vector2(line4.StartPoint.X, line4.StartPoint.Y), new Vector2(line4.EndPoint.X, line4.EndPoint.Y) };
                fun.drawBLine(dxf, lsline2, 0.3, contour);


                Line line5 = fun.mirrorline(new Line(v1, v2), v18, v19);
                Vector2[] lsline4 = { new Vector2(line5.StartPoint.X, line5.StartPoint.Y), new Vector2(line5.EndPoint.X, line5.EndPoint.Y) };
                fun.drawBLine(dxf, lsline4, 0.3, contour);
                Line line6 = fun.mirrorline(new Line(v3, v2), v18, v19);
                Vector2[] lsline5 = { new Vector2(line6.StartPoint.X, line6.StartPoint.Y), new Vector2(line6.EndPoint.X, line6.EndPoint.Y) };
                fun.drawBLine(dxf, lsline5, 0.3, contour);

                Line line7 = fun.mirrorline(new Line(v1, v2), v16, v17);
                Vector2[] lsline7 = { new Vector2(line7.StartPoint.X, line7.StartPoint.Y), new Vector2(line7.EndPoint.X, line7.EndPoint.Y) };
                fun.drawBLine(dxf, lsline7, 0.3, contour);
                Line line8 = fun.mirrorline(new Line(v3, v2), v16, v17);
                Vector2[] lsline8 = { new Vector2(line8.StartPoint.X, line8.StartPoint.Y), new Vector2(line8.EndPoint.X, line8.EndPoint.Y) };
                fun.drawBLine(dxf, lsline8, 0.3, contour);

                Vector2 v4 = new Vector2(line4.EndPoint.X, line4.EndPoint.Y);
                Vector2 v5 = new Vector2(line3.EndPoint.X, line3.EndPoint.Y);
                Vector2 v6 = new Vector2(line3.StartPoint.X, line3.StartPoint.Y);
                Vector2 v7 = new Vector2(line6.StartPoint.X, line6.StartPoint.Y);
                Vector2 v8 = new Vector2(line6.EndPoint.X, line6.EndPoint.Y);
                Vector2 v9 = new Vector2(line5.StartPoint.X, line5.StartPoint.Y);
                Vector2 v10 = new Vector2(line8.StartPoint.X, line8.StartPoint.Y);
                Vector2 v11 = new Vector2(line7.EndPoint.X, line7.EndPoint.Y);
                Vector2 v12 = new Vector2(line7.StartPoint.X, line7.StartPoint.Y);

                Vector2[] Line9 = { v3, v4 };
                fun.drawBLine(dxf, Line9, 0.3, contour);

                Vector2[] Line10 = { v12, v1 };
                fun.drawBLine(dxf, Line10, 0.3, contour);
                Vector2[] Line11 = { v6, v7 };
                fun.drawBLine(dxf, Line11, 0.3, contour);
                Vector2[] Line12 = { v9, v10 };
                fun.drawBLine(dxf, Line12, 0.3, contour);

                Circle circle00 = new Circle(v13, IC / 2);
                circle00.Layer = center;
                circle00.Lineweight = Lineweight.W50;
                circle00.Linetype = Linetype.DashDot;
                dxf.AddEntity(circle00);


                Vector2 v20 = new Vector2(v15.X + IC, v15.Y);
                Vector2 v21 = new Vector2(v20.X - S / 2 * Math.Sin(An_1), v20.Y + S / 2 * Math.Cos(An_1));
                Vector2 v23 = new Vector2(v20.X - S, v20.Y);
                Vector2 v22 = new Vector2(v23.X - S / 2 * Math.Cos(EPSR_1 - An_1), v23.Y + S / 2 * Math.Sin(EPSR_1 - An_1));
                Vector2 v24 = new Vector2(v12.X + 2 * L, v12.Y);
                Vector2 v25 = new Vector2(v24.X, v24.Y + L);
                Vector2 v26 = new Vector2(v25.X - S, v25.Y - S * Math.Tan(AS_1));
                Vector2 v27 = new Vector2(v24.X - S, v24.Y + S * Math.Tan(AS_1));

                Vector2 v28 = new Vector2(v24.X - 3, v24.Y);

                Vector2 v29 = new Vector2(v15.X + 5, v15.Y);
                Vector2 v30 = new Vector2(v12.X + 1.31, v12.Y + 0.31);
                Vector2 v31 = new Vector2(v15.X + 12.51, v15.Y - 8.37);

                List<Vector3> points00 = new List<Vector3>
                {
                  new Vector3(v22.X,v22.Y , 0),
                  new Vector3(v22.X+1,v22.Y+0.5 , 0),
                  new Vector3(v22.X+2,v22.Y , 0),


                  new Vector3(v21.X ,v21.Y, 0),


                };

                Spline spline00 = new Spline(points00);
                spline00.Layer = contour;
                DxfDocument doc00 = new DxfDocument();
                dxf.AddEntity(spline00);

                Vector2[] Line13 = { v23, v20 };
                fun.drawBLine(dxf, Line13, 0.3, contour);
                Vector2[] Line14 = { v23, v22 };
                fun.drawBLine(dxf, Line14, 0.3, contour);
                Vector2[] Line15 = { v20, v21 };
                fun.drawBLine(dxf, Line15, 0.3, contour);

                LwPolyline poly1 = new LwPolyline();
                poly1.Vertexes.Add(new LwPolylineVertex(v24));
                poly1.Vertexes.Add(new LwPolylineVertex(v25));
                poly1.Vertexes.Add(new LwPolylineVertex(v26));
                poly1.Vertexes.Add(new LwPolylineVertex(v27));
                poly1.Vertexes.Add(new LwPolylineVertex(v24));

                //            poly1.SetConstantWidth(0.05);
                poly1.IsClosed = true;
                fun.PolyFill(dxf, poly1, 0.4, contour);

                String[] htype1 = new String[100];
                Line[] hline1 = new Line[100];
                Arc[] harc1 = new Arc[100];
                int hnumst1 = poly1.Explode().Count;  //记录爆炸后，线段有多少
                for (int i = 0; i < hnumst1; i++)
                {
                    htype1[i] = poly1.Explode()[i].Type.ToString();    //将所有元素的类型记录成一个数组
                    if (htype1[i] == "Line")
                    {
                        hline1[i] = (Line)poly1.Explode()[i];
                    }
                    if (htype1[i] == "Arc")
                    {
                        harc1[i] = (Arc)poly1.Explode()[i];
                    }
                }
                fun.hatchsub1(dxf, htype1, hnumst1, 45, 5, hline1, harc1, hatching);


                //标注
                LinearDimension dim8 = new LinearDimension(new Line(v10, v11), offset, 235, dimensionStyle);
                dim8.UserText = "≈1";
                dxf.AddEntity(dim8);
                Angular2LineDimension angdim2 = new Angular2LineDimension(new Line(v10, v15), new Line(v10, v29), offset, dimensionStyle);
                angdim2.UserText = "37°30′";
                dxf.AddEntity(angdim2);
                Angular2LineDimension angdim6 = new Angular2LineDimension(new Line(v20, v23), (new Line(v20, v11)), offset + 3, dimensionStyle);
                angdim6.UserText = "15°±1°";
                dxf.AddEntity(angdim6);

                Angular2LineDimension angdim7 = new Angular2LineDimension(new Line(v24, v27), (new Line(v24, v28)), offset + 5, dimensionStyle);
                angdim7.UserText = "11°±1°";
                dxf.AddEntity(angdim7);
                LinearDimension dim1 = new LinearDimension(new Line(v4, v9), offset, 360, dimensionStyle);
                dim1.UserText = "l";
                dxf.AddEntity(dim1);

                LinearDimension dim2 = new LinearDimension(new Line(v1, v6), offset, 90, dimensionStyle);
                dim2.UserText = "l";
                dxf.AddEntity(dim2);
                LinearDimension dim3 = new LinearDimension(new Line(v14, v15), offset - 3, 360, dimensionStyle);
                dim3.UserText = "d";
                dxf.AddEntity(dim3);
                LinearDimension dim4 = new LinearDimension(new Line(v17, v12), offset, 120, dimensionStyle);
                dim4.UserText = "m";
                dxf.AddEntity(dim4);
                // LinearDimension dim5 = new LinearDimension(new Line(v21, v16), offset, 110, dimensionStyle);
                //dim5.UserText = "m";
                //dxf.AddEntity(dim5);
                LinearDimension dim6 = new LinearDimension(new Line(v25, v26), offset + 2, 360, dimensionStyle);
                dim6.UserText = "S";
                dxf.AddEntity(dim6);
                LinearDimension dim7 = new LinearDimension(new Line(v11, v12), offset, 197, dimensionStyle);
                dim7.UserText = "bs";
                dxf.AddEntity(dim7);




                Angular2LineDimension angdim1 = new Angular2LineDimension(new Line(v10, v15), new Line(v12, v17), offset + 3, dimensionStyle);
                angdim1.UserText = "εr";
                dxf.AddEntity(angdim1);


                Angular2LineDimension angdim3 = new Angular2LineDimension((new Line(v30, v9)), new Line(v30, v31), offset, dimensionStyle);
                angdim3.UserText = "xr＝75°";
                dxf.AddEntity(angdim3);


                Angular2LineDimension angdim5 = new Angular2LineDimension(new Line(v3, v4), (new Line(v12, v11)), offset + 19, dimensionStyle);
                angdim5.UserText = "φ";
                dxf.AddEntity(angdim5);



            }

            if (KRINS != 0 && AN == 20)
            {

                Vector2 v1 = new Vector2(0, 0);
                Vector2 v2 = new Vector2(v1.X - (BS * Math.Cos(EPSR_1 - KRINS_1)), v1.Y + (BS * Math.Sin(EPSR_1 - KRINS_1)));
                Vector2 v3 = new Vector2(v2.X - (BCH * Math.Sin(KCH_1)), v2.Y + BCH * Math.Cos(KCH_1));




                Vector2 v14 = new Vector2(v3.X, v1.Y + L / 2);
                Vector2 v15 = new Vector2(v14.X + L, v14.Y);
                Vector2 v16 = new Vector2(v14.X + L / 2, v1.Y + L);
                Vector2 v17 = new Vector2(v16.X, v16.Y - L);
                Vector2 v13 = new Vector2(v14.X + L / 2, v14.Y);
                Vector2 v18 = new Vector2(v3.X, v1.Y + L);
                Vector2 v19 = new Vector2(v3.X + L, v1.Y);


                Line line3 = fun.mirrorline(new Line(v1, v2), v14, v15);
                Vector2[] lsline1 = { new Vector2(line3.StartPoint.X, line3.StartPoint.Y), new Vector2(line3.EndPoint.X, line3.EndPoint.Y) };

                Line line4 = fun.mirrorline(new Line(v2, v3), v14, v15);
                Vector2[] lsline2 = { new Vector2(line4.StartPoint.X, line4.StartPoint.Y), new Vector2(line4.EndPoint.X, line4.EndPoint.Y) };



                Line line5 = fun.mirrorline(new Line(v1, v2), v18, v19);
                Vector2[] lsline4 = { new Vector2(line5.StartPoint.X, line5.StartPoint.Y), new Vector2(line5.EndPoint.X, line5.EndPoint.Y) };

                Line line6 = fun.mirrorline(new Line(v3, v2), v18, v19);
                Vector2[] lsline5 = { new Vector2(line6.StartPoint.X, line6.StartPoint.Y), new Vector2(line6.EndPoint.X, line6.EndPoint.Y) };


                Line line7 = fun.mirrorline(new Line(v1, v2), v16, v17);
                Vector2[] lsline7 = { new Vector2(line7.StartPoint.X, line7.StartPoint.Y), new Vector2(line7.EndPoint.X, line7.EndPoint.Y) };

                Line line8 = fun.mirrorline(new Line(v3, v2), v16, v17);
                Vector2[] lsline8 = { new Vector2(line8.StartPoint.X, line8.StartPoint.Y), new Vector2(line8.EndPoint.X, line8.EndPoint.Y) };


                Vector2 v4 = new Vector2(line4.EndPoint.X, line4.EndPoint.Y);
                Vector2 v5 = new Vector2(line3.EndPoint.X, line3.EndPoint.Y);
                Vector2 v6 = new Vector2(line3.StartPoint.X, line3.StartPoint.Y);
                Vector2 v7 = new Vector2(line6.StartPoint.X, line6.StartPoint.Y);
                Vector2 v8 = new Vector2(line6.EndPoint.X, line6.EndPoint.Y);
                Vector2 v9 = new Vector2(line5.StartPoint.X, line5.StartPoint.Y);
                Vector2 v10 = new Vector2(line8.StartPoint.X, line8.StartPoint.Y);
                Vector2 v11 = new Vector2(line7.EndPoint.X, line7.EndPoint.Y);
                Vector2 v12 = new Vector2(line7.StartPoint.X, line7.StartPoint.Y);

                Vector2[] Line9 = { v3, v4 };
                fun.drawBLine(dxf, Line9, 0.3, contour);

                Vector2[] Line10 = { v12, v1 };
                fun.drawBLine(dxf, Line10, 0.3, contour);
                Vector2[] Line11 = { v6, v7 };
                fun.drawBLine(dxf, Line11, 0.3, contour);
                Vector2[] Line12 = { v9, v10 };
                fun.drawBLine(dxf, Line12, 0.3, contour);

                Vector2[] Line13 = { v4, v6 };
                fun.drawBLine(dxf, Line13, 0.3, contour);
                Vector2[] Line14 = { v7, v9 };
                fun.drawBLine(dxf, Line14, 0.3, contour);
                Vector2[] Line15 = { v1, v3 };
                fun.drawBLine(dxf, Line15, 0.3, contour);
                Vector2[] Line16 = { v12, v10 };
                fun.drawBLine(dxf, Line16, 0.3, contour);



                Circle circle00 = new Circle(v13, IC / 2);
                circle00.Layer = center;
                circle00.Lineweight = Lineweight.W50;
                circle00.Linetype = Linetype.DashDot;
                dxf.AddEntity(circle00);


                Vector2 v20 = new Vector2(v15.X + IC, v15.Y);
                Vector2 v21 = new Vector2(v20.X - S / 2 * Math.Sin(An_1), v20.Y + S / 2 * Math.Cos(An_1));
                Vector2 v23 = new Vector2(v20.X - S, v20.Y);
                Vector2 v22 = new Vector2(v23.X - S / 2 * Math.Cos(EPSR_1 - An_1), v23.Y + S / 2 * Math.Sin(EPSR_1 - An_1));
                Vector2 v24 = new Vector2(v12.X + 2 * L, v12.Y);
                Vector2 v25 = new Vector2(v24.X, v24.Y + L);
                Vector2 v26 = new Vector2(v25.X - S, v25.Y - S * Math.Tan(AS_1));
                Vector2 v27 = new Vector2(v24.X - S, v24.Y + S * Math.Tan(AS_1));

                Vector2 v28 = new Vector2(v24.X - 3, v24.Y);

                Vector2 v29 = new Vector2(v15.X + 5, v15.Y);
                Vector2 v30 = new Vector2(v12.X + 1.31, v12.Y + 0.31);
                Vector2 v31 = new Vector2(v15.X + 12.51, v15.Y - 8.37);

                List<Vector3> points00 = new List<Vector3>
           {
                 new Vector3(v22.X,v22.Y , 0),
               new Vector3(v22.X+1,v22.Y+0.5 , 0),
               new Vector3(v22.X+2,v22.Y , 0),


                  new Vector3(v21.X ,v21.Y, 0),


            };

                Spline spline00 = new Spline(points00);
                spline00.Layer = contour;
                DxfDocument doc00 = new DxfDocument();
                dxf.AddEntity(spline00);

                Vector2[] Line113 = { v23, v20 };
                fun.drawBLine(dxf, Line113, 0.3, contour);
                Vector2[] Line114 = { v23, v22 };
                fun.drawBLine(dxf, Line114, 0.3, contour);
                Vector2[] Line115 = { v20, v21 };
                fun.drawBLine(dxf, Line115, 0.3, contour);

                LwPolyline poly1 = new LwPolyline();
                poly1.Vertexes.Add(new LwPolylineVertex(v24));
                poly1.Vertexes.Add(new LwPolylineVertex(v25));
                poly1.Vertexes.Add(new LwPolylineVertex(v26));
                poly1.Vertexes.Add(new LwPolylineVertex(v27));
                poly1.Vertexes.Add(new LwPolylineVertex(v24));

                //            poly1.SetConstantWidth(0.05);
                poly1.IsClosed = true;
                fun.PolyFill(dxf, poly1, 0.4, contour);

                String[] htype1 = new String[100];
                Line[] hline1 = new Line[100];
                Arc[] harc1 = new Arc[100];
                int hnumst1 = poly1.Explode().Count;  //记录爆炸后，线段有多少
                for (int i = 0; i < hnumst1; i++)
                {
                    htype1[i] = poly1.Explode()[i].Type.ToString();    //将所有元素的类型记录成一个数组
                    if (htype1[i] == "Line")
                    {
                        hline1[i] = (Line)poly1.Explode()[i];
                    }
                    if (htype1[i] == "Arc")
                    {
                        harc1[i] = (Arc)poly1.Explode()[i];
                    }
                }
                fun.hatchsub1(dxf, htype1, hnumst1, 45, 5, hline1, harc1, hatching);





                LinearDimension dim1 = new LinearDimension(new Line(v4, v9), offset, 360, dimensionStyle);
                dim1.UserText = "l";
                dxf.AddEntity(dim1);

                LinearDimension dim2 = new LinearDimension(new Line(v1, v6), offset, 90, dimensionStyle);
                dim2.UserText = "l";
                dxf.AddEntity(dim2);
                LinearDimension dim3 = new LinearDimension(new Line(v14, v15), offset - 3, 360, dimensionStyle);
                dim3.UserText = "d";
                dxf.AddEntity(dim3);
                LinearDimension dim4 = new LinearDimension(new Line(v17, v12), offset, 120, dimensionStyle);
                dim4.UserText = "m";
                dxf.AddEntity(dim4);
                // LinearDimension dim5 = new LinearDimension(new Line(v21, v16), offset, 110, dimensionStyle);
                //dim5.UserText = "m";
                //dxf.AddEntity(dim5);
                LinearDimension dim6 = new LinearDimension(new Line(v25, v26), offset + 2, 360, dimensionStyle);
                dim6.UserText = "S";
                dxf.AddEntity(dim6);
                LinearDimension dim7 = new LinearDimension(new Line(v11, v12), offset, 197, dimensionStyle);
                dim7.UserText = "bs";
                dxf.AddEntity(dim7);




                Angular2LineDimension angdim1 = new Angular2LineDimension(new Line(v10, v15), new Line(v12, v17), offset + 3, dimensionStyle);
                angdim1.UserText = "εr";
                dxf.AddEntity(angdim1);


                Angular2LineDimension angdim3 = new Angular2LineDimension((new Line(v30, v9)), new Line(v30, v31), offset, dimensionStyle);
                angdim3.UserText = "xr＝75°";
                dxf.AddEntity(angdim3);


                Angular2LineDimension angdim5 = new Angular2LineDimension(new Line(v3, v4), (new Line(v12, v11)), offset + 19, dimensionStyle);
                angdim5.UserText = "φ";
                dxf.AddEntity(angdim5);

                Angular2LineDimension angdim8 = new Angular2LineDimension(new Line(v20, v23), (new Line(v20, v11)), offset + 3, dimensionStyle);
                angdim8.UserText = "20°±30°";
                dxf.AddEntity(angdim8);

                Angular2LineDimension angdim9 = new Angular2LineDimension(new Line(v24, v27), (new Line(v24, v28)), offset + 5, dimensionStyle);
                angdim9.UserText = "20°±30°";
                dxf.AddEntity(angdim9);

            }

            fun.SetLayer(dxf);
            fun.SetByLayer(dxf);





            dxf.DrawingVariables.AcadVer = DxfVersion.AutoCad2007;
            dxf.Save(path);
           


        }

        public static void _TrigonInsert(Dictionary<string, Object> data)    //镶式六边形刀片
        {
            DxfDocument dxf = new DxfDocument();
            dxf.Layers["0"].Lineweight = Lineweight.W25;
            Layer contour = new Layer("contour");//轮廓层
            Layer dimensioning = new Layer("dimensioning");//尺寸层
            Layer refin = new Layer("refin");//基准线/内轮廓/虚线
            Layer center = new Layer("center");//中心线
            Layer textlayer = new Layer("textlayer");//文本层
            Layer hatching = new Layer("hatching");//填充层
            Layer additionalline = new Layer("additionalline");//附加线
            Layer cutting = new Layer("cutting");//切削层
            fun.SetLayer(dxf);

            //double tic = Convert.ToDouble(data["ic"]);
            //double scale = Convert.ToDouble(data["scale"]); //放大系数
            double tic = 0;
            double scale = 1; //放大系数


            if (scale == 0 && tic < 9)
            {
                scale = 3.0;
            }
            else if (scale == 0 && tic < 20)
            {
                scale = 2.0;
            }
            else if (scale == 0)
            {
                scale = 1.5;
            }

            double pi = Math.PI;
            double DIM = Convert.ToDouble(data["dim"]);
            double ic = Convert.ToDouble(data["ic"]) * scale;
            double s = Convert.ToDouble(data["s"]) * scale;
            double d1 = Convert.ToDouble(data["d1"]) * scale;
            double re = Convert.ToDouble(data["re"]) * scale;
            double epsr = Convert.ToDouble(data["epsr"]) * pi / 180;
            double an = Convert.ToDouble(data["an"]) * pi / 180;
            int ifs = (int)Convert.ToDecimal(data["ifs"]);
            int cb = (int)Convert.ToDecimal(data["cb"]);
            string path = Convert.ToString(data["path"]);
            double dxc = 0.80;
            double ictc = Convert.ToDouble(data["ictc"]);
            double stc = Convert.ToDouble(data["stc"]);
            double d1tc = Convert.ToDouble(data["d1tc"]);
            double m = Convert.ToDouble(data["m"]);
            double le = Convert.ToDouble(data["l"]);
            double l1 = Convert.ToDouble(data["le"]);
            /*
            double pi = Math.PI;
            double DIM = 1;
            double ic =9.525;
            double s = 4.76;
            double d1 = 3.81;
            double re =0.4;
            double epsr = 80 * pi / 180;
            double an = 0 * pi / 180;
            int ifs = 2;
            int cb = 0;
            string path = Convert.ToString(data["path"]);
            double dxc = 0.80;
            double ictc = 0;
            double stc = 0;
            double d1tc = 0;
            */
            double ang1 = 40 * pi / 180;
            double ang2 = 80 * pi / 180;
            double ang3 = 10 * pi / 180;
            double ang4 = 30 * pi / 180;
            double dis1 = (ic / 2) / Math.Sin(ang1);
            double dis2 = (ic / 2) / Math.Sin(ang2);
            Vector2 p1 = new Vector2(0, 0);
            Vector2 p0 = new Vector2(le * Math.Cos(ang3), (ic / 2) / Math.Cos(ang3));
            Vector2 p2 = new Vector2(p0.X, p1.Y);
            Vector2 p3 = fun.Polar(p2, ang3, le);
            Vector2 p4 = fun.Polar(p3, pi - (ang2 - ang3), le);
            Vector2 p5 = fun.Polar(p0, pi / 2, dis1);
            Vector2 p6 = fun.Polar(p0, pi - ang4, dis2);
            Vector2 p7 = fun.Polar(p0, pi + ang4, dis1);
            Vector2 p2p = fun.Polar(p2, pi / 2, re / Math.Sin(ang2));
            Vector2 p3p = fun.Polar(p3, pi - ang4, re / Math.Sin(ang1));
            Vector2 p4p = fun.Polar(p4, pi + ang4, re / Math.Sin(ang2));
            Vector2 p5p = fun.Polar(p5, -0.5 * pi, re / Math.Sin(ang1));
            Vector2 p6p = fun.Polar(p6, -ang4, re / Math.Sin(ang2));
            Vector2 p7p = fun.Polar(p7, ang4, re / Math.Sin(ang1));
            Vector2 p8 = fun.Polar(p2, pi - ang3, re / Math.Tan(ang2));
            Vector2 p9 = fun.Polar(p2, ang3, re / Math.Tan(ang2));
            Vector2 p10 = fun.Polar(p3, pi + ang3, re / Math.Tan(ang1));
            Vector2 p11 = fun.Polar(p3, pi - (ang2 - ang3), re / Math.Tan(ang1));
            Vector2 p12 = fun.Polar(p4, ang3 - ang2, re / Math.Tan(ang2));
            Vector2 p13 = fun.Polar(p4, pi - (ang2 - ang4), re / Math.Tan(ang2));
            Vector2 p14 = fun.Polar(p5, ang4 - ang2, re / Math.Tan(ang1));
            Vector2 p15 = fun.Polar(p5, pi + ang2 - ang4, re / Math.Tan(ang1));
            Vector2 p16 = fun.Polar(p6, ang2 - ang4, re / Math.Tan(ang2));
            Vector2 p17 = fun.Polar(p6, pi + ang2 - ang3, re / Math.Tan(ang2));
            Vector2 p18 = fun.Polar(p7, ang2 - ang3, re / Math.Tan(ang1));
            Vector2 p19 = fun.Polar(p7, -ang3, re / Math.Tan(ang1));
            Vector2 p30 = fun.Polar(p5, ang4 - ang2, l1);
            Vector2 p31 = fun.Polar(p5, pi + ang2 - ang4, l1);
            //标注
            Vector2 p32 = fun.Polar(p0, pi / 2, dis1);
            Vector2 p33 = fun.Polar(p0, pi / 2, ic / 2);

            Vector2 p20 = fun.Polar(p0, 0, 2 * ic);
            Vector2 p21 = new Vector2(p20.X, fun.Polar(p5p, pi / 2, re).Y);
            Vector2 p22 = fun.Polar(p21, pi + an, s / Math.Cos(an));
            Vector2 p24 = new Vector2(p20.X, fun.Polar(p2p, -pi / 2, re).Y); ;
            Vector2 p23 = fun.Polar(p24, pi - an, s / Math.Cos(an));





            Vector2 v1 = fun.Polar(p0, -150 * pi / 180, ic / 2 / Math.Sin(40 * pi / 180) * dxc);
            Vector2 v2 = fun.Polar(p0, -90 * pi / 180, ic / 2 / Math.Sin(80 * pi / 180) * dxc);
            Vector2 v4 = fun.Polar(p0, -30 * pi / 180, ic / 2 / Math.Sin(40 * pi / 180) * dxc);
            Vector2 v5 = fun.Polar(p0, 30 * pi / 180, ic / 2 / Math.Sin(80 * pi / 180) * dxc);
            Vector2 v3 = fun.Polar(p0, 90 * pi / 180, ic / 2 / Math.Sin(40 * pi / 180) * dxc);
            Vector2 v6 = fun.Polar(p0, 150 * pi / 180, ic / 2 / Math.Sin(80 * pi / 180) * dxc);


            if (cb == 1 || cb == 2)
            {
                LwPolyline Line01 = new LwPolyline();
                Line01.Vertexes.Add(new LwPolylineVertex(v1));
                Line01.Vertexes.Add(new LwPolylineVertex(v2));
                Line01.Vertexes.Add(new LwPolylineVertex(v4));
                Line01.Vertexes.Add(new LwPolylineVertex(v5));
                Line01.Vertexes.Add(new LwPolylineVertex(v3));
                Line01.Vertexes.Add(new LwPolylineVertex(v6));
                Line01.Vertexes.Add(new LwPolylineVertex(v1));
                Line01.Lineweight = Lineweight.W35;
                Line01.Layer = additionalline;
                dxf.AddEntity(Line01);
            }



            Circle circle2 = new Circle(p0, ic / 2);
            circle2.Layer = refin;
            circle2.Linetype = Linetype.DashDot;
            dxf.AddEntity(circle2);
            Arc arc5 = fun.DrawArc(p14, p5p, p15);

            LwPolyline poly11 = new LwPolyline();
            poly11.Vertexes.Add(new LwPolylineVertex(p8));
            poly11.Vertexes.Add(new LwPolylineVertex(p2));
            poly11.Vertexes.Add(new LwPolylineVertex(p3));
            poly11.Vertexes.Add(new LwPolylineVertex(p4));
            poly11.Vertexes.Add(new LwPolylineVertex(p14));
            poly11.Vertexes[4].Bulge = Math.Tan((pi - epsr) / 4);
            poly11.Vertexes.Add(new LwPolylineVertex(p15));
            poly11.Vertexes.Add(new LwPolylineVertex(p6));
            poly11.Vertexes.Add(new LwPolylineVertex(p7));
            poly11.Vertexes.Add(new LwPolylineVertex(p8));
            poly11.IsClosed = true;
            fun.PolyFill(dxf, poly11, 0.5, contour);

            LwPolyline poly111 = new LwPolyline();
            poly111.Vertexes.Add(new LwPolylineVertex(p30));
            poly111.Vertexes.Add(new LwPolylineVertex(p31));
            poly111.Vertexes.Add(new LwPolylineVertex(p15));
            poly111.Vertexes.Add(new LwPolylineVertex(p14));
            poly111.Vertexes.Add(new LwPolylineVertex(p30));
            poly111.IsClosed = true;
            fun.PolyFill(dxf, poly111, 0.5, contour);
            String[] htype1 = new String[100];
            Line[] hline1 = new Line[100];
            Arc[] harc1 = new Arc[100];
            int hnumst1 = poly111.Explode().Count;  //记录爆炸后，线段有多少
            for (int i = 0; i < hnumst1; i++)
            {
                htype1[i] = poly111.Explode()[i].Type.ToString();    //将所有元素的类型记录成一个数组
                if (htype1[i] == "Line")
                {
                    hline1[i] = (Line)poly111.Explode()[i];
                }
                if (htype1[i] == "Arc")
                {
                    harc1[i] = (Arc)poly111.Explode()[i];
                }
            }
            fun.hatchsub1(dxf, htype1, hnumst1, 45, 1, hline1, harc1, hatching);

            String[] htype2 = new String[100];
            Line[] hline2 = new Line[100];
            Arc[] harc2 = new Arc[100];
            int hnumst2 = poly111.Explode().Count;  //记录爆炸后，线段有多少
            for (int i = 0; i < hnumst2; i++)
            {
                htype2[i] = poly111.Explode()[i].Type.ToString();    //将所有元素的类型记录成一个数组
                if (htype1[i] == "Line")
                {
                    hline2[i] = (Line)poly111.Explode()[i];
                }
                if (htype2[i] == "Arc")
                {
                    harc2[i] = (Arc)poly111.Explode()[i];
                }
            }
            fun.hatchsub1(dxf, htype2, hnumst2, 135, 1, hline2, harc2, hatching);



            LwPolyline line00 = new LwPolyline();
            line00.Vertexes.Add(new LwPolylineVertex(p2));
            line00.Vertexes.Add(new LwPolylineVertex(p3));
            line00.Vertexes.Add(new LwPolylineVertex(p4));
            line00.Vertexes.Add(new LwPolylineVertex(p5));
            line00.Vertexes.Add(new LwPolylineVertex(p6));
            line00.Vertexes.Add(new LwPolylineVertex(p7));
            line00.Vertexes.Add(new LwPolylineVertex(p2));
            line00.Lineweight = Lineweight.W25;
            line00.Layer = additionalline;
            dxf.AddEntity(line00);

            //insert.inserthole(dxf, p0, v2, v3, p20, p21, scale, data);

            Line cenline1 = new Line(fun.Polar(p0, pi, ic / 2 + 0.5), fun.Polar(p0, 0, ic / 2 + 0.5));
            cenline1.Layer = center;
            cenline1.Linetype = Linetype.Center;
            Line cenline2 = new Line(fun.Polar(p0, pi / 2, ic + 0.5), fun.Polar(p0, -0.5 * pi, ic / 2 + 0.5));
            cenline2.Layer = center;
            cenline2.Linetype = Linetype.Center;
            Line cenline3 = new Line(fun.Polar(p20, pi, s + 0.5), fun.Polar(p20, 0, 0.5));
            cenline3.Layer = center;
            cenline3.Linetype = Linetype.Center;
            dxf.AddEntity(cenline1);
            dxf.AddEntity(cenline2);
            dxf.AddEntity(cenline3);
            fun.jz(dxf, fun.Polar(fun.Polar(p0, pi / 2, ic / 2), 180 * pi / 180, 10 * scale), 90, 3, "A");
            DimensionStyle dimensionStyle = new DimensionStyle("sd");
            dimensionStyle.ArrowSize = 1.6;
            dimensionStyle.DimArrow1 = DimensionArrowhead.Closedfilled;
            dimensionStyle.DimArrow2 = DimensionArrowhead.Closedfilled;
            dimensionStyle.TextHeight = 1.2;
            double offset = 10;

            double v100 = fun.CalDistance(p32, p33);//计算两点间距离

            //标注




            if (DIM == 0)
            {

                LinearDimension dim1 = new LinearDimension(new Line(fun.Polar(p0, pi / 2, ic / 2), fun.Polar(p0, -0.5 * pi, ic / 2)), offset * scale, 90, dimensionStyle);
                dim1.UserText = "IC";
                dxf.AddEntity(dim1);

                LinearDimension dim2 = new LinearDimension(new Line(p23, p24), offset, 180, dimensionStyle);
                dim1.UserText = "S";
                dxf.AddEntity(dim2);
                //LinearDimension dim3 = new LinearDimension(new Line(p32,p33 ), offset * scale, 90, dimensionStyle);
                //dim3.UserText = "M";
                //dxf.AddEntity(dim3);
                fun.dimrot1(dxf, p32, p33, 90, offset * scale * 1.5, 2, 1.2, 1.6, 0.9, "  M", "", "");

                Angular2LineDimension dim4 = new Angular2LineDimension(new Line(p5, fun.Polar(p5, epsr / 2, 0.1)), new Line(p5, fun.Polar(p5, pi - epsr / 2, 0.1)), offset * 0.8, dimensionStyle);
                dim4.UserText = "EPSR";
                dxf.AddEntity(dim4);

                //LinearDimension dim5 = new LinearDimension(new Line(p5, p30), offset * scale*0.8, -45, dimensionStyle);
                //dim5.UserText = "L1";
                //dxf.AddEntity(dim5);
                fun.dimrot1(dxf, p5, p30, -45, offset * scale, 2, 1.2, 1.6, 0.9, "  L1", "", "");

                fun.dimrot1(dxf, p2, p3, -170, offset * scale * 0.8, 2, 1.2, 1.6, 0.9, "  L", "", "");

                if (re / scale != 0.001)
                {
                    RadialDimension dimrad1 = new RadialDimension(arc5, 147, offset, dimensionStyle);//DimensionStyle.Default);
                    dimrad1.UserText = "RE";
                    dxf.AddEntity(dimrad1);
                }

                if (an != 0)
                {
                    Angular2LineDimension dimang2 = new Angular2LineDimension(new Line(p23, fun.Polar(p23, pi - an, 1)), new Line(p24, fun.Polar(p24, pi, 1)), s + offset, dimensionStyle);
                    dimang2.UserText = "AN=" + an * 180 / pi + "°";
                    dxf.AddEntity(dimang2);
                }
            }

            else
            {
                if (ictc == 0)
                {
                    LinearDimension dim1 = new LinearDimension(new Line(fun.Polar(p0, pi / 2, ic / 2), fun.Polar(p0, -0.5 * pi, ic / 2)), offset * scale, 90, dimensionStyle);
                    dim1.UserText = String.Format("IC={0}", ic / scale);
                    dxf.AddEntity(dim1);
                }


                if (ictc != 0)
                {
                    LinearDimension dim1 = new LinearDimension(new Line(fun.Polar(p0, pi / 2, ic / 2), fun.Polar(p0, -0.5 * pi, ic / 2)), offset * scale, 90, dimensionStyle);
                    dim1.UserText = String.Format("IC={0}±{1}", ic / scale, ictc);
                    dxf.AddEntity(dim1);
                }
                if (stc == 0)
                {
                    LinearDimension dim2 = new LinearDimension(new Line(p23, p24), offset, 180, dimensionStyle);
                    dim2.UserText = String.Format("S={0}", s / scale);
                    dxf.AddEntity(dim2);
                }
                if (stc != 0)
                {
                    LinearDimension dim2 = new LinearDimension(new Line(p23, p24), offset, 180, dimensionStyle);
                    dim2.UserText = String.Format("S={0}±{1}", s / scale, stc);
                    dxf.AddEntity(dim2);
                }


                LinearDimension dim11 = new LinearDimension(new Line(fun.Polar(p0, pi / 2, ic / 2), fun.Polar(p0, -0.5 * pi, ic / 2)), offset * scale, 90, dimensionStyle);
                dim11.UserText = String.Format("IC={0}", ic / scale);
                dxf.AddEntity(dim11);

                LinearDimension dim22 = new LinearDimension(new Line(p23, p24), offset, 180, dimensionStyle);
                dim22.UserText = String.Format("S={0}", s / scale);
                dxf.AddEntity(dim22);

                /*LinearDimension dim33 = new LinearDimension(new Line(p32,p33), offset * scale*1.5, 90, dimensionStyle);
                dim33.UserText = String.Format("M={0}", m  / scale);
                dxf.AddEntity(dim33);
                */

                fun.dimrot1(dxf, p32, p33, 90, offset * scale * 1.5, 2, 1.2, 1.6, 0.9, "M=" + m, "", "");

                //LinearDimension dim44 = new LinearDimension(new Line(p5, p30), offset * scale * 0.8, -45, dimensionStyle);
                //dim44.UserText = String.Format("L1={0}", l1  / scale);
                // dxf.AddEntity(dim44);

                fun.dimrot1(dxf, p5, p30, -45, offset * scale, 2, 1.2, 1.6, 0.9, "  L1=" + l1, "", "");

                fun.dimrot1(dxf, p2, p3, -170, offset * scale * 0.8, 2, 1.2, 1.6, 0.9, "  L=" + le, "", "");

                Angular2LineDimension dim4 = new Angular2LineDimension(new Line(p5, fun.Polar(p5, epsr / 2 + ang3, 0.1)), new Line(p5, fun.Polar(p5, epsr / 2 + pi / 2, 0.1)), offset * 0.8, dimensionStyle);
                dim4.UserText = String.Format("EPSR={0}°", epsr * 180 / pi);
                dxf.AddEntity(dim4);

                if (re / scale != 0.001)
                {
                    RadialDimension dimrad1 = new RadialDimension(arc5, 147, offset, dimensionStyle);//DimensionStyle.Default);
                    dimrad1.UserText = String.Format("RE={0}", re / scale);
                    dxf.AddEntity(dimrad1);
                }

                if (an != 0)
                {
                    Angular2LineDimension dimang2 = new Angular2LineDimension(new Line(p23, fun.Polar(p23, pi - an, 1)), new Line(p24, fun.Polar(p24, pi, 1)), s + offset, dimensionStyle);
                    dimang2.UserText = "AN=" + an * 180 / pi + "°";
                    dxf.AddEntity(dimang2);
                }

            }

            // double isframe = Convert.ToDouble(data["isframe"]);
            // if (isframe == 1)
            {
                Dictionary<string, Vector2> position = Frame.frameA4Y(dxf, new Vector2(p0.X - 90, p0.Y + 120), data);
                fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");

            }

            fun.SetLayer(dxf);
            fun.SetByLayer(dxf);
            dxf.DrawingVariables.AcadVer = DxfVersion.AutoCad2007;
            dxf.Save(path);

        }

        public static void HandReamer(Dictionary<string, Object> data)    //手用铰刀
        {
            DxfDocument dxf = new DxfDocument();
            dxf.Layers["0"].Lineweight = Lineweight.W25;
            Layer contour = new Layer("contour");//轮廓层
            Layer dimensioning = new Layer("dimensioning");//尺寸层
            Layer refin = new Layer("refin");//基准线/内轮廓/虚线
            Layer center = new Layer("center");//中心线
            Layer textlayer = new Layer("textlayer");//文本层
            Layer hatching = new Layer("hatching");//填充层
            Layer additionalline = new Layer("additionalline");//附加线
            Layer cutting = new Layer("cutting");//切削层
            fun.SetLayer(dxf);
            /*
            double tic = Convert.ToDouble(data["ic"]);
            double scale = Convert.ToDouble(data["scale"]); //放大系数
            if (scale == 0 && tic < 9)
            {
                scale = 3.0;
            }
            else if (scale == 0 && tic < 20)
            {
                scale = 2.5;
            }
            else if (scale == 0)
            {
                scale = 2.0;
            }
            */
            /*
            string path = Convert.ToString(data["path"]);
            double pi = Math.PI;
            double d=1.6;
            double l1 = 21;
            double l = 44;
            double a = 1.25;
            double l4 = 4;
            double eper = 90;
            double eper_ = 90 * pi / 180;
            double zh_ = 189.0 / 710;
            double zj_ = 72.0 / 1285;
            double zj = d/6*2.5;
            double zjc = l * zj_;
            double zjg = (d / 2) - zj;
            double qm = 221.0 / 2056;
            */
            double scale = Convert.ToDouble(data["scale"]); //放大系数
            string path = Convert.ToString(data["path"]);
            double pi = Math.PI;
            double d = Convert.ToDouble(data["dc"])* scale;
            double l1 = Convert.ToDouble(data["l"]) * scale;
            double l = Convert.ToDouble(data["oal"]) * scale;
            double a = Convert.ToDouble(data["drvsc"]) * scale;
            double l4 = Convert.ToDouble(data["l4"]) * scale;
            double eper = Convert.ToDouble(data["eper"]);
            double eper_ = eper * pi / 180;
            double zh_ = 189.0 / 710;
            double zj_ = 72.0 / 1285;
            double zj = d / 6 * 2.5;
            double zjc = l * zj_;
            double zjg = (d / 2) - zj;
            double qm = 221.0 / 2056;
            Vector2 p0 = new Vector2(0, 0);
            Vector2 p1 = fun.Polar(p0, pi / 2, d / 2);
            Vector2 p2 = fun.Polar(p1, pi, ((d - (d * zh_)) / 2.0) / 2.0);
            Vector2 p3 = fun.Polar(p1, pi, l4);
            Vector2 p4 = fun.Polar(p3, pi, l - l1 - l4 - zjc);
            Vector2 p5 = fun.Polar(p4, pi / -2, zjg);
            Vector2 p6 = fun.Polar(p5, pi, zjc);
            Vector2 p7 = fun.Polar(p6, pi / 2, zjg);

            Vector2 p8 = fun.Polar(p7, pi, l1 - l * qm);
            Vector2 p9 = new Vector2(-l, d / 6 * 2);
            Vector2 p11 = fun.Polar(p0, pi, ((d - (d * zh_)) / 2) / 2);
            Vector2 p12 = fun.Polar(p11, pi / 2, d / 2 - (((d - (d * zh_)) / 2.0) / 2.0));
            Vector2 p13 = fun.Polar(p12, pi / -2, ((d - (d * zh_)) / 2.0) / 2.0);
            Vector2 p14 = fun.Polar(p9, pi / -2, d / 6 * 2);
            Vector2 p17 = fun.Polar(p3, pi / -2, (d - d * zh_) / 2);
            Vector2 p18 = fun.Polar(p4, pi / -2, d);
            Vector2 p20 = fun.Polar(p7, -pi / 4, d / 6 / (Math.Cos(pi / 4)));
            Vector2 p21 = fun.Polar(p20, pi, d / 6);
            Vector2 p22 = fun.Polar(p21, pi / -2, d / 6);
            Vector2 p23 = fun.Polar(p22, -pi / 4, d / 6 / (Math.Cos(pi / 4)));
            Vector2 p24 = fun.Polar(p23, pi, d / 6);
            Vector2 p25 = fun.Polar(p24, pi / -2, d / 6);
            Vector2 p26 = fun.Polar(p25, -pi / 4, d / 6 / (Math.Cos(pi / 4)));
            Vector2 p27 = fun.Polar(p26, pi, d / 6);

            Vector2 p28 = fun.Polar(p9, pi / -2, d / 6);
            Vector2 p29 = fun.Polar(p28, pi / -2, d / 6);
            Vector2 p30 = fun.Polar(p29, pi / -2, d / 6);
            Vector2 p31 = fun.Polar(p30, pi / -2, d / 6);
            Vector2 p35 = fun.Polar(p7, -pi / 4, (p7.Y - p6.Y) / Math.Cos((eper_ / 2)));
            Vector2 p19 = fun.Polar(p7, pi / -2, d);
            Vector2 p36 = fun.Polar(p9, -eper_ - eper_ / 2, ((d / 6) * 2) / Math.Cos(eper_ / 2));
            Vector2 p37 = fun.Polar(p0, pi / 2, (d * zh_ / 2) + ((d - d * zh_) / 2 / 2));
            Vector2 p38 = fun.Polar(p0, pi / -2, (d * zh_ / 2) + ((d - d * zh_) / 2 / 2));
            Vector2 p39 = fun.Polar(p36, pi, l4 * 2);
            Vector2 p40 = fun.Polar(p39, pi / 2, a * Math.Cos(pi / 4));
            Vector2 p41 = fun.Polar(p40, pi + pi / 4, a);
            Vector2 p42 = fun.Polar(p41, -pi / 4, a);
            Vector2 p43 = fun.Polar(p42, pi / 4, a);





            //镜像线
            Vector2 p10 = new Vector2(-200, 0);

            Vector2 p15 = fun.mirrorpoint(p13, p0, p10);

            Vector2 p16 = fun.mirrorpoint(p2, p0, p10);
            Vector2 p32 = fun.mirrorpoint(p8, p0, p10);


            //中心线
            Vector2 p33 = fun.Polar(p0, 0, 4);
            Vector2 p34 = fun.Polar(p0, pi, l + 4);
            Vector2 p44 = fun.Polar(p39, 0, a * 1.5);
            Vector2 p45 = fun.Polar(p39, pi, a * 1.5);
            Vector2 p46 = fun.Polar(p39, pi / 2, a * 1.5);
            Vector2 p47 = fun.Polar(p39, pi / -2, a * 1.5);







            Line Line1 = fun.mirrorline(new Line(p2, p3), p0, p10);
            Vector2[] line1 = { new Vector2(Line1.StartPoint.X, Line1.StartPoint.Y), new Vector2(Line1.EndPoint.X, Line1.EndPoint.Y) };
            fun.drawBLine(dxf, line1, 0.125, contour);

            Line Line2 = fun.mirrorline(new Line(p3, p4), p0, p10);
            Vector2[] line2 = { new Vector2(Line2.StartPoint.X, Line2.StartPoint.Y), new Vector2(Line2.EndPoint.X, Line2.EndPoint.Y) };
            fun.drawBLine(dxf, line2, 0.125, contour);

            Line Line3 = fun.mirrorline(new Line(p4, p5), p0, p10);
            Vector2[] line3 = { new Vector2(Line3.StartPoint.X, Line3.StartPoint.Y), new Vector2(Line3.EndPoint.X, Line3.EndPoint.Y) };
            fun.drawBLine(dxf, line3, 0.125, contour);

            Line Line4 = fun.mirrorline(new Line(p5, p6), p0, p10);
            Vector2[] line4 = { new Vector2(Line4.StartPoint.X, Line4.StartPoint.Y), new Vector2(Line4.EndPoint.X, Line4.EndPoint.Y) };
            fun.drawBLine(dxf, line4, 0.125, contour);

            Line Line5 = fun.mirrorline(new Line(p6, p7), p0, p10);
            Vector2[] line5 = { new Vector2(Line5.StartPoint.X, Line5.StartPoint.Y), new Vector2(Line5.EndPoint.X, Line5.EndPoint.Y) };
            fun.drawBLine(dxf, line5, 0.125, contour);

            Line Line6 = fun.mirrorline(new Line(p7, p8), p0, p10);
            Vector2[] line6 = { new Vector2(Line6.StartPoint.X, Line6.StartPoint.Y), new Vector2(Line6.EndPoint.X, Line6.EndPoint.Y) };
            fun.drawBLine(dxf, line6, 0.125, contour);

            Line Line7 = fun.mirrorline(new Line(p8, p9), p0, p10);
            Vector2[] line7 = { new Vector2(Line7.StartPoint.X, Line7.StartPoint.Y), new Vector2(Line7.EndPoint.X, Line7.EndPoint.Y) };
            fun.drawBLine(dxf, line7, 0.125, contour);

            Line Line8 = fun.mirrorline(new Line(p11, p13), p0, p10);
            Vector2[] line8 = { new Vector2(Line8.StartPoint.X, Line8.StartPoint.Y), new Vector2(Line8.EndPoint.X, Line8.EndPoint.Y) };
            fun.drawBLine(dxf, line8, 0.125, contour);


            Line Line9 = fun.mirrorline(new Line(p9, p14), p0, p10);
            Vector2[] line9 = { new Vector2(Line9.StartPoint.X, Line9.StartPoint.Y), new Vector2(Line9.EndPoint.X, Line9.EndPoint.Y) };
            fun.drawBLine(dxf, line9, 0.125, contour);

            Line Line10 = fun.mirrorline(new Line(p13, p17), p0, p10);
            Vector2[] line10 = { new Vector2(Line10.StartPoint.X, Line10.StartPoint.Y), new Vector2(Line10.EndPoint.X, Line10.EndPoint.Y) };
            fun.drawBLine(dxf, line10, 0.125, contour);

            Line Line11 = fun.mirrorline(new Line(p17, p3), p0, p10);
            Vector2[] line11 = { new Vector2(Line11.StartPoint.X, Line11.StartPoint.Y), new Vector2(Line11.EndPoint.X, Line11.EndPoint.Y) };
            fun.drawBLine(dxf, line11, 0.125, contour);



            LwPolyline poly1 = new LwPolyline();
            poly1.Vertexes.Add(new LwPolylineVertex(p11));
            poly1.Vertexes.Add(new LwPolylineVertex(p13));
            poly1.Vertexes[1].Bulge = Math.Tan((eper_ * 2) / 4);
            poly1.Vertexes.Add(new LwPolylineVertex(p2));
            poly1.Vertexes.Add(new LwPolylineVertex(p3));
            poly1.Vertexes.Add(new LwPolylineVertex(p4));
            poly1.Vertexes.Add(new LwPolylineVertex(p5));
            poly1.Vertexes.Add(new LwPolylineVertex(p35));
            poly1.Vertexes.Add(new LwPolylineVertex(p7));
            poly1.Vertexes.Add(new LwPolylineVertex(p8));
            poly1.Vertexes.Add(new LwPolylineVertex(p9));
            poly1.Vertexes.Add(new LwPolylineVertex(p14));
            fun.PolyFill(dxf, poly1, 0.125, contour);

            LwPolyline poly2 = new LwPolyline();
            poly2.Vertexes.Add(new LwPolylineVertex(p15));
            poly2.Vertexes[0].Bulge = Math.Tan((eper_ * 2) / -4);
            poly2.Vertexes.Add(new LwPolylineVertex(p16));
            fun.PolyFill(dxf, poly2, 0.125, contour);




            LwPolyline poly3 = new LwPolyline();
            poly3.Vertexes.Add(new LwPolylineVertex(p13));
            poly3.Vertexes.Add(new LwPolylineVertex(p17));
            poly3.Vertexes.Add(new LwPolylineVertex(p3));
            fun.PolyFill(dxf, poly3, 0.125, contour);

            LwPolyline poly4 = new LwPolyline();
            poly4.Vertexes.Add(new LwPolylineVertex(p4));
            poly4.Vertexes.Add(new LwPolylineVertex(p18));
            fun.PolyFill(dxf, poly4, 0.125, contour);





            LwPolyline poly6 = new LwPolyline();
            poly6.Vertexes.Add(new LwPolylineVertex(p7));
            poly6.Vertexes.Add(new LwPolylineVertex(p20));
            poly6.Vertexes.Add(new LwPolylineVertex(p21));
            poly6.Vertexes.Add(new LwPolylineVertex(p22));
            poly6.Vertexes.Add(new LwPolylineVertex(p23));
            poly6.Vertexes.Add(new LwPolylineVertex(p24));
            poly6.Vertexes.Add(new LwPolylineVertex(p25));
            poly6.Vertexes.Add(new LwPolylineVertex(p26));
            poly6.Vertexes.Add(new LwPolylineVertex(p27));
            fun.PolyFill(dxf, poly6, 0.125, contour);

            LwPolyline poly7 = new LwPolyline();
            poly7.Vertexes.Add(new LwPolylineVertex(p20));
            poly7.Vertexes.Add(new LwPolylineVertex(p21));
            poly7.Vertexes.Add(new LwPolylineVertex(p9));
            poly7.Vertexes.Add(new LwPolylineVertex(p28));
            poly7.Vertexes.Add(new LwPolylineVertex(p22));
            poly7.Vertexes.Add(new LwPolylineVertex(p23));
            poly7.Vertexes.Add(new LwPolylineVertex(p29));
            poly7.Vertexes.Add(new LwPolylineVertex(p30));
            poly7.Vertexes.Add(new LwPolylineVertex(p25));
            poly7.Vertexes.Add(new LwPolylineVertex(p26));
            poly7.Vertexes.Add(new LwPolylineVertex(p31));
            poly7.Vertexes.Add(new LwPolylineVertex(p32));
            poly7.Vertexes.Add(new LwPolylineVertex(p19));
            poly7.Vertexes.Add(new LwPolylineVertex(p27));
            fun.PolyFill(dxf, poly7, 0.125, contour);

            LwPolyline poly8 = new LwPolyline();
            poly8.Vertexes.Add(new LwPolylineVertex(p37));
            poly8.Vertexes.Add(new LwPolylineVertex(p38));
            fun.PolyFill(dxf, poly8, 0.125, contour);

            LwPolyline poly9 = new LwPolyline();
            poly9.Vertexes.Add(new LwPolylineVertex(p41));
            poly9.Vertexes.Add(new LwPolylineVertex(p42));
            poly9.Vertexes.Add(new LwPolylineVertex(p43));
            poly9.Vertexes.Add(new LwPolylineVertex(p40));
            poly9.Vertexes.Add(new LwPolylineVertex(p41));
            poly9.Vertexes[4].Bulge = Math.Tan((eper_ * 2) / -4);
            poly9.Vertexes.Add(new LwPolylineVertex(p43));
            poly9.Vertexes[5].Bulge = Math.Tan((eper_ * 2) / -4);
            poly9.Vertexes.Add(new LwPolylineVertex(p41));
            fun.PolyFill(dxf, poly9, 0.125, contour);












            Line line13 = new Line(p9, p36);
            Line line14 = new Line(p36, p31);
            line13.Linetype = Linetype.Dashed;
            line13.Lineweight = Lineweight.W35;
            line13.Layer = refin;
            dxf.AddEntity(line13);
            line14.Linetype = Linetype.Dashed;
            line14.Lineweight = Lineweight.W35;
            line14.Layer = refin;
            dxf.AddEntity(line14);





            //中心线
            Line line12 = new Line(p33, p34);
            line12.Linetype = Linetype.DashDot;
            line12.Lineweight = Lineweight.W25;
            line12.Layer = center;
            dxf.AddEntity(line12);

            Line line15 = new Line(p44, p45);
            line15.Linetype = Linetype.DashDot;
            line15.Lineweight = Lineweight.W25;
            line15.Layer = center;
            dxf.AddEntity(line15);

            Line line16 = new Line(p46, p47);
            line16.Linetype = Linetype.DashDot;
            line16.Lineweight = Lineweight.W25;
            line16.Layer = center;
            dxf.AddEntity(line16);
            //标注


            fun.dimrot1(dxf, p37, p9, 180, l1 / 2, 2, 1.2, 1.6, 0.9, "  l=" + l/ scale, "", "");
            fun.dimrot1(dxf, p27, p9, 180, l1 / 4, 2, 1.2, 1.6, 0.9, "  l1=" + l1 / scale, "", "");
            fun.dimrot1(dxf, p37, p17, 180, l1 / 4, 2, 1.2, 1.6, 0.9, "  l4=" + l4 / scale, "", "");
            fun.dimrot1(dxf, p8, p32, 90, 0, 2, 1.2, 1.6, 0.9, "  d=" + d / scale, "", "");
            fun.dimrot1(dxf, p41, p42, 135, l1 / 2, 2, 1.2, 1.6, 0.9, "  a=" + a / scale, "", "");



            double isframe = Convert.ToInt32(data["isframe"]);
            String isframe_chose = Convert.ToString(data["isframe_chose"]);
            if (isframe == 1)
            {
                if (isframe_chose.Equals("0"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA0X(dxf, new Vector2(p0.X - 1189 / 2.0, p0.Y + 841 / 2.0), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }

                if (isframe_chose.Equals("1"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA1X(dxf, new Vector2(p0.X - 841 / 2.0, p0.Y + 594 / 2.0), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }

                if (isframe_chose.Equals("2"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA2X(dxf, new Vector2(p0.X - 594 / 2.0, p0.Y + 420 / 2.0), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }

                if (isframe_chose.Equals("3"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA3X(dxf, new Vector2(p0.X - 420 / 2.0, p0.Y + 297 / 2.0), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }

                if (isframe_chose.Equals("4X"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA4X(dxf, new Vector2(p0.X - 297 / 2.0, p0.Y + 210 / 2.0 - 10 * 2.26), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }

                if (isframe_chose.Equals("4Y"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA4Y(dxf, new Vector2(p0.X - 210 / 2.0, p0.Y + 297 / 2.0), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }
            }
            fun.SetLayer(dxf);
            fun.SetByLayer(dxf);

            dxf.DrawingVariables.AcadVer = DxfVersion.AutoCad2007;
            dxf.Save(path);
            

        }

        public static void Straightshankmachinereamer(Dictionary<string, Object> data)    //直柄和莫氏锥柄机用铰刀
        {
            DxfDocument dxf = new DxfDocument();
            dxf.Layers["0"].Lineweight = Lineweight.W25;
            Layer contour = new Layer("contour");//轮廓层
            Layer dimensioning = new Layer("dimensioning");//尺寸层
            Layer refin = new Layer("refin");//基准线/内轮廓/虚线
            Layer center = new Layer("center");//中心线
            Layer textlayer = new Layer("textlayer");//文本层
            Layer hatching = new Layer("hatching");//填充层
            Layer additionalline = new Layer("additionalline");//附加线
            Layer cutting = new Layer("cutting");//切削层
            fun.SetLayer(dxf);
            /*
            double scale = 1;
            string path = Convert.ToString(data["path"]);
            double pi = Math.PI;
            double d1 = 1.4;
            double d2 = 1.4;
            double l1 = 40;
            double l2 = 8;
            double l3 = 32;
            double eper = 80;
            double eper_ = eper  * pi / 180;
            double zj = 127 / 141.0;
            double qm = 6.0 / 41;
            double dj = 1.0 / 3;
            double djd = d2 / Math.Sqrt(2)/4;
           */
            /*
            string path = Convert.ToString(data["path"]);
            double pi = Math.PI;
            double scale = 1;
           double d1 = 5.5* scale;
            double d2 = 5.6*scale;
            double l1 = 93* scale;
            double l2 = 26* scale;
            double l3 = 36* scale;
            double eper = 80;
            */
            /*
            double scale = 1;
            string path = Convert.ToString(data["path"]);
            double pi = Math.PI;
            double d1 =5.5;
            double d2 = 1.4;
            double l1 = 138;
            double l2 =26;


            double l3 = 32*46.0/25.0;
            double eper = 80;
            double eper_ = eper * pi / 180;
            double zj = 127 / 141.0;
            double qm = 6.0 / 41;
            double dj = 1.0 / 3;
            double djd = d2 / Math.Sqrt(2) / 4;
            double msyz = 1;
            */
            double scale = Convert.ToDouble(data["scale"]); //放大系数
            if (scale == 0)
            {
                scale = 1;


            }


            string path = Convert.ToString(data["path"]);
            double pi = Math.PI;
            double d1 = Convert.ToDouble(data["dc"])* scale;
            double d2 = Convert.ToDouble(data["dcon"]) * scale;
            double l1 = Convert.ToDouble(data["oal"]) * scale;
            double l2 = Convert.ToDouble(data["lu"]) * scale;
            double l3 = Convert.ToDouble(data["ls"]) * scale;
            double eper = Convert.ToDouble(data["eper"]);

            double eper_ = eper * pi / 180;
            double zj = 127 / 141.0;
            double qm = 6.0 / 41;
            double dj = 1.0 / 3;//中间的比例
            double djd = d2 / Math.Sqrt(2) / 4;//倒角
            double msyz = Convert.ToDouble(data["msyz"]);







            Vector2 p0 = new Vector2(0, 0);
            Vector2 p00 = fun.Polar(p0, pi / 2 + (pi - eper / 2), d2 / Math.Sqrt(2) - djd);
            Vector2 p1;
            Vector2 p2;
            Vector2 p3;
            if (d1 < 5.5)
            {
                p1 = fun.Polar(p0, pi / 2 + (pi - eper / 2), d2 / Math.Sqrt(2));
                p2 = fun.Polar(p1, pi, l3);
                p3 = fun.Polar(p2, pi / -2, (d2 - (d2 * zj)) / 2.0);

            }
            else
            {
                p1 = fun.Polar(p0, pi / 2 + (pi - eper / 2), d1 / Math.Sqrt(2) + 3);
                p2 = fun.Polar(p0, pi / 2 + (pi - eper / 2), d1 / Math.Sqrt(2) + 3);
                p3 = fun.Polar(p1, pi / -2, p1.Y / 2.0);

            }
            Vector2 p4 = fun.Polar(p3, pi, l1 - l2);

            //Vector2 p5 = fun.Polar(p4, pi / 2, (d1 * zj) / 2.0);
            Vector2 p5 = new Vector2(p4.X, d1 / 2);
            Vector2 p6 = fun.Polar(p5, pi, l2 - (p5.Y - p4.Y));
            Vector2 p7 = fun.Polar(p6, pi + pi / 4, (p5.Y - p4.Y) / Math.Cos(pi / 4));
            Vector2 p8 = fun.Polar(p7, pi / -2, (d1 - ((p5.Y - p4.Y) * 2)) * dj);
            Vector2 p9 = fun.Polar(p8, pi / -2, (d1 - ((p5.Y - p4.Y) * 2)) * dj / 2.0);
            Vector2 p99 = fun.Polar(p9, 0, l2);
            Vector2 p10 = fun.Polar(p6, pi + pi / 4, d1 * Math.Cos(pi / 4));
            Vector2 p36 = fun.Polar(p8, 0, l2);
            Vector2 p37 = fun.Polar(p36, 0, (p7.Y - p8.Y));


            Vector2 p11 = fun.Polar(p1, pi, l1 - l2);
            Vector2 p12 = fun.Polar(p11, pi, l2 - (p5.Y - p4.Y));
            Vector2 p13 = fun.Polar(p12, pi + pi / 4, (p5.Y - p4.Y) / Math.Cos(pi / 4));
            Vector2 p14 = fun.Polar(p13, pi / -2, (d1 - (d1 * qm * 2)) * dj);
            Vector2 p15 = fun.Polar(p14, pi / -2, (d1 - (d1 * qm * 2)) * dj / 2.0);
            Vector2 p16 = fun.Polar(p14, 0, l2 - ((p13.Y - p14.Y) / 2.0));
            Vector2 p17 = fun.Polar(p16, pi / 2, p13.Y - p14.Y);
            Vector2 p27 = fun.Polar(p12, pi + eper_ / 2, d2 / Math.Sqrt(2));
            //中间线
            Vector2 zj1 = fun.Polar(p0, pi, l1 + 8);

            // System.Diagnostics.Debug.WriteLine((pi - eper_ / 2));
            // System.Diagnostics.Debug.WriteLine(pi );
            Vector2 p18 = fun.mirrorpoint(p00, p0, zj1);
            Vector2 p19 = fun.mirrorpoint(p1, p0, zj1);
            Vector2 p20 = fun.mirrorpoint(p11, p0, zj1);
            Vector2 p21 = fun.mirrorpoint(p12, p0, zj1);
            Vector2 p22 = fun.mirrorpoint(p13, p0, zj1);
            Vector2 p23 = fun.mirrorpoint(p14, p0, zj1);
            Vector2 p24 = fun.mirrorpoint(p15, p0, zj1);
            Vector2 p25 = fun.mirrorpoint(p16, p0, zj1);
            Vector2 p26 = fun.mirrorpoint(p17, p0, zj1);

            Vector2 p28 = fun.mirrorpoint(p2, p0, zj1);
            Vector2 p29 = fun.mirrorpoint(p3, p0, zj1);
            Vector2 p30 = fun.mirrorpoint(p4, p0, zj1);
            Vector2 p31 = fun.mirrorpoint(p5, p0, zj1);
            Vector2 p32 = fun.mirrorpoint(p6, p0, zj1);
            Vector2 p33 = fun.mirrorpoint(p7, p0, zj1);
            Vector2 p34 = fun.mirrorpoint(p8, p0, zj1);
            Vector2 p35 = fun.mirrorpoint(p9, p0, zj1);
            Vector2 p38 = fun.mirrorpoint(p37, p0, zj1);
            Vector2 p39 = fun.mirrorpoint(p36, p0, zj1);



            if (d1 <= 3.75 * scale)
            {
                LwPolyline poly1 = new LwPolyline();
                poly1.Vertexes.Add(new LwPolylineVertex(p00));
                poly1.Vertexes.Add(new LwPolylineVertex(p1));
                poly1.Vertexes.Add(new LwPolylineVertex(p11));
                poly1.Vertexes.Add(new LwPolylineVertex(p12));
                poly1.Vertexes.Add(new LwPolylineVertex(p13));

                poly1.Vertexes.Add(new LwPolylineVertex(p14));
                poly1.Vertexes.Add(new LwPolylineVertex(p16));
                poly1.Vertexes[6].Bulge = Math.Tan((pi) / 4);
                poly1.Vertexes.Add(new LwPolylineVertex(p17));
                poly1.Vertexes.Add(new LwPolylineVertex(p13));
                poly1.Vertexes.Add(new LwPolylineVertex(p12));
                poly1.Vertexes.Add(new LwPolylineVertex(p11));
                poly1.Vertexes.Add(new LwPolylineVertex(p17));
                poly1.Vertexes.Add(new LwPolylineVertex(p13));
                poly1.Vertexes.Add(new LwPolylineVertex(fun.Polar(p13, pi / -2, p5.Y - p4.Y)));
                poly1.Vertexes.Add(new LwPolylineVertex(fun.Polar(p13, 0, Math.Abs(p7.X - p6.X))));
                poly1.Vertexes.Add(new LwPolylineVertex(p12));
                poly1.Vertexes.Add(new LwPolylineVertex(p13));
                poly1.Vertexes.Add(new LwPolylineVertex(p15));
                fun.PolyFill(dxf, poly1, 0.05, contour);

                LwPolyline poly2 = new LwPolyline();
                poly2.Vertexes.Add(new LwPolylineVertex(p00));
                poly2.Vertexes.Add(new LwPolylineVertex(p18));
                poly2.Vertexes.Add(new LwPolylineVertex(p19));
                poly2.Vertexes.Add(new LwPolylineVertex(p1));
                poly2.Vertexes.Add(new LwPolylineVertex(p19));
                poly2.Vertexes.Add(new LwPolylineVertex(p20));
                poly2.Vertexes.Add(new LwPolylineVertex(p21));
                poly2.Vertexes.Add(new LwPolylineVertex(p22));
                poly2.Vertexes.Add(new LwPolylineVertex(p23));
                poly2.Vertexes.Add(new LwPolylineVertex(p25));
                poly2.Vertexes[9].Bulge = -Math.Tan((pi) / 4);
                poly2.Vertexes.Add(new LwPolylineVertex(p26));
                poly2.Vertexes.Add(new LwPolylineVertex(p22));
                poly2.Vertexes.Add(new LwPolylineVertex(p21));
                poly2.Vertexes.Add(new LwPolylineVertex(p20));
                poly2.Vertexes.Add(new LwPolylineVertex(p26));
                poly2.Vertexes.Add(new LwPolylineVertex(p22));
                poly2.Vertexes.Add(new LwPolylineVertex(fun.Polar(p22, pi / 2, p5.Y - p4.Y)));
                poly2.Vertexes.Add(new LwPolylineVertex(fun.Polar(p22, 0, Math.Abs(p7.X - p6.X))));
                poly2.Vertexes.Add(new LwPolylineVertex(p21));
                poly2.Vertexes.Add(new LwPolylineVertex(p22));
                poly2.Vertexes.Add(new LwPolylineVertex(p15));
                fun.PolyFill(dxf, poly2, 0.05, contour);


                fun.dimrot1(dxf, p12, p00, 180, l1 / 4, 2, 1.2, 1.6, 0.9, "  l1=" + l1 / scale, "", "");
                fun.dimrot1(dxf, p21, p20, 180, l1 / 8, 2, 1.2, 1.6, 0.9, "  l2=" + l2 / scale, "", "");
                fun.dimrot1(dxf, p19, p1, -90, d2 * 2, 2, 1.2, 1.6, 0.9, "  d2=" + d2 / scale, "", "");
                fun.dimrot1(dxf, p21, p12, 90, l1 / 6, 2, 1.2, 1.6, 0.9, "  d1=" + d1 / scale, "", "");



            }
            else if (d1 > 3.75 * scale && d1 < 5.5 * scale)
            {
                LwPolyline poly1 = new LwPolyline();
                poly1.Vertexes.Add(new LwPolylineVertex(p00));
                poly1.Vertexes.Add(new LwPolylineVertex(p1));
                poly1.Vertexes.Add(new LwPolylineVertex(p19));
                poly1.Vertexes.Add(new LwPolylineVertex(p18));
                poly1.Vertexes.Add(new LwPolylineVertex(p00));
                poly1.Vertexes.Add(new LwPolylineVertex(p1));
                poly1.Vertexes.Add(new LwPolylineVertex(p2));
                poly1.Vertexes.Add(new LwPolylineVertex(p3));
                poly1.Vertexes.Add(new LwPolylineVertex(p4));
                poly1.Vertexes.Add(new LwPolylineVertex(p5));
                poly1.Vertexes.Add(new LwPolylineVertex(p6));
                poly1.Vertexes.Add(new LwPolylineVertex(p7));
                poly1.Vertexes.Add(new LwPolylineVertex(fun.Polar(p7, 0, Math.Abs(p7.X - p6.X))));
                poly1.Vertexes.Add(new LwPolylineVertex(p6));
                poly1.Vertexes.Add(new LwPolylineVertex(fun.Polar(p7, 0, Math.Abs(p7.X - p6.X))));
                poly1.Vertexes.Add(new LwPolylineVertex(fun.Polar(p7, pi / -2, p5.Y - p4.Y)));
                poly1.Vertexes.Add(new LwPolylineVertex(p34));
                poly1.Vertexes.Add(new LwPolylineVertex(fun.Polar(p34, 0, Math.Abs(p7.X - p6.X))));
                poly1.Vertexes.Add(new LwPolylineVertex(fun.Polar(p8, 0, Math.Abs(p7.X - p6.X))));
                poly1.Vertexes.Add(new LwPolylineVertex(p8));
                poly1.Vertexes.Add(new LwPolylineVertex(fun.Polar(p33, pi / 2, p5.Y - p4.Y)));

                poly1.Vertexes.Add(new LwPolylineVertex(fun.Polar(p33, 0, Math.Abs(p7.X - p6.X))));
                poly1.Vertexes.Add(new LwPolylineVertex(p32));
                poly1.Vertexes.Add(new LwPolylineVertex(p33));
                poly1.Vertexes.Add(new LwPolylineVertex(p32));
                poly1.Vertexes.Add(new LwPolylineVertex(p31));
                poly1.Vertexes.Add(new LwPolylineVertex(p30));
                poly1.Vertexes.Add(new LwPolylineVertex(p29));
                poly1.Vertexes.Add(new LwPolylineVertex(p28));
                poly1.Vertexes.Add(new LwPolylineVertex(p19));
                fun.PolyFill(dxf, poly1, 0.1, contour);


                LwPolyline poly2 = new LwPolyline();
                poly2.Vertexes.Add(new LwPolylineVertex(p4));
                poly2.Vertexes.Add(new LwPolylineVertex(p37));
                poly2.Vertexes.Add(new LwPolylineVertex(p8));
                poly2.Vertexes.Add(new LwPolylineVertex(p7));
                poly2.Vertexes.Add(new LwPolylineVertex(p4));
                poly2.Vertexes.Add(new LwPolylineVertex(p37));


                poly2.Vertexes.Add(new LwPolylineVertex(p36));
                poly2.Vertexes.Add(new LwPolylineVertex(p39));
                poly2.Vertexes.Add(new LwPolylineVertex(p38));
                poly2.Vertexes.Add(new LwPolylineVertex(p34));
                poly2.Vertexes.Add(new LwPolylineVertex(p33));
                poly2.Vertexes.Add(new LwPolylineVertex(p30));
                poly2.Vertexes.Add(new LwPolylineVertex(p38));
                poly2.Vertexes.Add(new LwPolylineVertex(p30));
                poly2.Vertexes.Add(new LwPolylineVertex(p31));
                poly2.Vertexes.Add(new LwPolylineVertex(p32));
                poly2.Vertexes.Add(new LwPolylineVertex(p33));
                poly2.Vertexes.Add(new LwPolylineVertex(p29));
                poly2.Vertexes.Add(new LwPolylineVertex(p3));

                fun.PolyFill(dxf, poly2, 0.1, contour);



                fun.dimrot1(dxf, p32, p18, 180, l1 / 4, 2, 1.2, 1.6, 0.9, "  l1=" + l1/ scale, "", "");
                fun.dimrot1(dxf, p32, p31, 180, l1 / 8, 2, 1.2, 1.6, 0.9, "  l2=" + l2 / scale, "", "");
                fun.dimrot1(dxf, p28, p18, 180, l1 / 4, 2, 1.2, 1.6, 0.9, "  l3=" + l3 / scale, "", "");
                fun.dimrot1(dxf, p19, p1, -90, d2 * 2, 2, 1.2, 1.6, 0.9, "  d2=" + d2 / scale, "", "");
                fun.dimrot1(dxf, p32, p6, 90, l1 / 6, 2, 1.2, 1.6, 0.9, "  d1=" + d1 / scale, "", "");

            }

            else
            {

                LwPolyline poly1 = new LwPolyline();

                poly1.Vertexes.Add(new LwPolylineVertex(p4));
                poly1.Vertexes.Add(new LwPolylineVertex(p5));
                poly1.Vertexes.Add(new LwPolylineVertex(p6));
                poly1.Vertexes.Add(new LwPolylineVertex(p7));

                poly1.Vertexes.Add(new LwPolylineVertex(p34));
                poly1.Vertexes.Add(new LwPolylineVertex(fun.Polar(p34, 0, p5.Y - p4.Y)));
                poly1.Vertexes.Add(new LwPolylineVertex(fun.Polar(p8, 0, p5.Y - p4.Y)));
                poly1.Vertexes.Add(new LwPolylineVertex(p8));
                poly1.Vertexes.Add(new LwPolylineVertex(fun.Polar(p7, pi / -2, p5.Y - p4.Y)));
                poly1.Vertexes.Add(new LwPolylineVertex(fun.Polar(p6, pi / -2, p5.Y - p4.Y)));
                poly1.Vertexes.Add(new LwPolylineVertex(p6));
                poly1.Vertexes.Add(new LwPolylineVertex(p7));
                poly1.Vertexes.Add(new LwPolylineVertex(p33));
                poly1.Vertexes.Add(new LwPolylineVertex(p32));
                poly1.Vertexes.Add(new LwPolylineVertex(fun.Polar(p32, pi / 2, p5.Y - p4.Y)));

                poly1.Vertexes.Add(new LwPolylineVertex(fun.Polar(p33, pi / 2, p5.Y - p4.Y)));

                poly1.Vertexes.Add(new LwPolylineVertex(p33));
                poly1.Vertexes.Add(new LwPolylineVertex(p32));
                poly1.Vertexes.Add(new LwPolylineVertex(p31));
                poly1.Vertexes.Add(new LwPolylineVertex(p30));
                fun.PolyFill(dxf, poly1, 0.2, contour);
                //dxf.AddEntity(poly1);

                LwPolyline poly2 = new LwPolyline();
                poly2.Vertexes.Add(new LwPolylineVertex(p4));
                poly2.Vertexes.Add(new LwPolylineVertex(p37));
                poly2.Vertexes.Add(new LwPolylineVertex(p8));
                poly2.Vertexes.Add(new LwPolylineVertex(p7));
                poly2.Vertexes.Add(new LwPolylineVertex(p4));
                poly2.Vertexes.Add(new LwPolylineVertex(p37));


                poly2.Vertexes.Add(new LwPolylineVertex(p36));
                poly2.Vertexes.Add(new LwPolylineVertex(p39));
                poly2.Vertexes.Add(new LwPolylineVertex(p38));
                poly2.Vertexes.Add(new LwPolylineVertex(p34));
                poly2.Vertexes.Add(new LwPolylineVertex(p33));
                poly2.Vertexes.Add(new LwPolylineVertex(p30));
                poly2.Vertexes.Add(new LwPolylineVertex(p38));
                poly2.Vertexes.Add(new LwPolylineVertex(p30));
                poly2.Vertexes.Add(new LwPolylineVertex(p31));
                poly2.Vertexes.Add(new LwPolylineVertex(p32));
                poly2.Vertexes.Add(new LwPolylineVertex(p33));


                fun.PolyFill(dxf, poly2, 0.2, contour);


                Milling_cutter.Morse_tapershank(dxf, p99, d1, l1, l2, msyz, 0);

                fun.dimrot1(dxf, p32, p18, 180, l1 / 4, 2, 1.2, 1.6, 0.9, "  l1=" + l1 / scale, "", "");
                fun.dimrot1(dxf, p32, p31, 180, l1 / 8, 2, 1.2, 1.6, 0.9, "  l2=" + l2 / scale, "", "");
                fun.dimrot1(dxf, p32, p6, 90, l1 / 6, 2, 1.2, 1.6, 0.9, "  d1=" + d1 / scale, "", "");
            }

            Line line1;
            if (d1 < 5.5 * scale)
            {
                //中心线
                line1 = new Line(p0, zj1);
                line1.Linetype = Linetype.DashDot;
                line1.Lineweight = Lineweight.W25;
                line1.Layer = center;
                dxf.AddEntity(line1);
                /*
                LwPolyline poly1 = new LwPolyline();
                poly1.Vertexes.Add(new LwPolylineVertex(p));
                fun.PolyFill(dxf, poly1, 0.125, contour);
                */
                Line line2 = new Line(p12, p27);
                line2.Linetype = Linetype.Dashed;
                line2.Lineweight = Lineweight.W35;
                line2.Layer = refin;
                dxf.AddEntity(line2);
                Line line3 = new Line(p27, p21);
                line3.Linetype = Linetype.Dashed;
                line3.Lineweight = Lineweight.W35;
                line3.Layer = refin;
                dxf.AddEntity(line3);
                Line line4 = new Line(p1, p0);
                line4.Linetype = Linetype.Dashed;
                line4.Lineweight = Lineweight.W35;
                line4.Layer = refin;
                dxf.AddEntity(line4);
                Line line5 = new Line(p0, p19);
                line5.Linetype = Linetype.Dashed;
                line5.Lineweight = Lineweight.W35;
                line5.Layer = refin;
                dxf.AddEntity(line5);
            }
            else
            {
                //中心线
                line1 = new Line(p0, zj1);
                line1.Linetype = Linetype.DashDot;
                line1.Lineweight = Lineweight.W25;
                line1.Layer = center;
                dxf.AddEntity(line1);
                /*
                LwPolyline poly1 = new LwPolyline();
                poly1.Vertexes.Add(new LwPolylineVertex(p));
                fun.PolyFill(dxf, poly1, 0.125, contour);
                */
                Line line2 = new Line(p6, p10);
                line2.Linetype = Linetype.Dashed;
                line2.Lineweight = Lineweight.W35;
                line2.Layer = refin;
                dxf.AddEntity(line2);
                Line line3 = new Line(p10, p32);
                line3.Linetype = Linetype.Dashed;
                line3.Lineweight = Lineweight.W35;
                line3.Layer = refin;
                dxf.AddEntity(line3);

            }

            double isframe = Convert.ToInt32(data["isframe"]);
            String isframe_chose = Convert.ToString(data["isframe_chose"]);
            if (isframe == 1)
            {
                if (isframe_chose.Equals("0"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA0X(dxf, new Vector2(p0.X - 1189 / 2.0, p0.Y + 841 / 2.0), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }

                if (isframe_chose.Equals("1"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA1X(dxf, new Vector2(p0.X - 841 / 2.0, p0.Y + 594 / 2.0), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }

                if (isframe_chose.Equals("2"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA2X(dxf, new Vector2(p0.X - 594 / 2.0, p0.Y + 420 / 2.0), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }

                if (isframe_chose.Equals("3"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA3X(dxf, new Vector2(p0.X - 420 / 2.0, p0.Y + 297 / 2.0), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }

                if (isframe_chose.Equals("4X"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA4X(dxf, new Vector2(p0.X - 297 / 2.0, p0.Y + 210 / 2.0 - 10 * 2.26), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }

                if (isframe_chose.Equals("4Y"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA4Y(dxf, new Vector2(p0.X - 210 / 2.0, p0.Y + 297 / 2.0), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }
            }
            fun.SetLayer(dxf);
            fun.SetByLayer(dxf);

            dxf.DrawingVariables.AcadVer = DxfVersion.AutoCad2007;
            dxf.Save(path);


           
        }

        public static void Angleareamerwithedge(Dictionary<string, Object> data)    //带刃倾角铰刀
        {
            DxfDocument dxf = new DxfDocument();
            dxf.Layers["0"].Lineweight = Lineweight.W25;
            Layer contour = new Layer("contour");//轮廓层
            Layer dimensioning = new Layer("dimensioning");//尺寸层
            Layer refin = new Layer("refin");//基准线/内轮廓/虚线
            Layer center = new Layer("center");//中心线
            Layer textlayer = new Layer("textlayer");//文本层
            Layer hatching = new Layer("hatching");//填充层
            Layer additionalline = new Layer("additionalline");//附加线
            Layer cutting = new Layer("cutting");//切削层
            fun.SetLayer(dxf);

            /*
            double scale = 1;
            string path = Convert.ToString(data["path"]);
            double pi = Math.PI;
            double d = 5.5;
            double d1 = 5.6;
            double L = 93;
            double l = 26;
            double l1 = 36;            
            double eper = 80;
            double eper_ = eper  * pi / 180;        
            double msyz = 1;
            double bl = 1.0 / 4;
            double bl1 = d * bl;
            double bl2 = bl1 / 2.0;
            double dj = 1;
            double yhj = 3.30;
            */
            /*
            double scale = 1;
            string path = Convert.ToString(data["path"]);
            double pi = Math.PI;
            double d = 8;
            double d1 = 0;
            double L =156;
            double l = 33;
            double l1 = 0;
            double eper = 80;
            double eper_ = eper * pi / 180;
            double msyz = 1;
            double bl = 1.0 / 4;
            double bl1 = d * bl;
            double bl2 = bl1 / 2.0;
            double dj = 1;
            double yhj = 1.0/10;
            */
            double scale = Convert.ToDouble(data["scale"]); //放大系数
            if (scale == 0)
            {
                scale = 1;


            }


            string path = Convert.ToString(data["path"]);
            double pi = Math.PI;
            double d = Convert.ToDouble(data["dc"]);
            double d1 = Convert.ToDouble(data["dcon"]);
            double L = Convert.ToDouble(data["oal"]);
            double l = Convert.ToDouble(data["l"]);
            double l1 = Convert.ToDouble(data["ls"]);
            double eper = 80;
            double eper_ = eper * pi / 180;
            double msyz = Convert.ToDouble(data["msyz"]);
            double bl = 1.0 / 4;
            double bl1 = d * bl;
            double bl2 = bl1 / 2.0;
            double dj = Convert.ToDouble(data["dj"]);
            double yhj = 1.0 / 10;

            Vector2 p0 = new Vector2(0, 0);
            Vector2 p1 = fun.Polar(p0, 0, bl2);
            Vector2 p2 = fun.Polar(p1, 0, bl2);
            Vector2 p3 = fun.Polar(p0, pi / 2, bl1);
            Vector2 p4 = fun.Polar(p3, pi / 2, bl2);
            Vector2 p5 = fun.Polar(p4, pi / 4, bl2 * (Math.Cos(pi / 4)));
            Vector2 p6 = fun.Polar(p4, pi / 2, bl2);
            Vector2 p7 = fun.Polar(p6, pi, l - bl1);
            Vector2 p8 = fun.Polar(p7, pi + pi / 4, bl2 / (Math.Cos(pi / 4)));
            Vector2 p9 = fun.Polar(p8, pi + pi / 4, bl2 / (Math.Cos(pi / 4)));
            Vector2 p10 = fun.Polar(p9, pi / -2, bl2);
            Vector2 p11 = fun.Polar(p10, pi / -2, bl2);

            Vector2 p12 = fun.Polar(p11, 5 * pi / 180, l * yhj);
            Vector2 p12_ = fun.Polar(p10, -5 * pi / 180, l * yhj);
            Vector2 p13 = fun.Polar(p7, pi / -2, d / 2.0);
            Vector2 p14 = fun.Polar(p0, pi / -2, bl2);
            Vector2 p15 = fun.Polar(p14, pi / -2, bl2);
            Vector2 p16 = fun.Polar(p15, pi / -2, bl1);


            Vector2 p17 = fun.Polar(p16, pi / 4, (d / 2 - ((3.27 / 4.04 * d) / 2)) / Math.Cos(pi / 4));
            Vector2 p18 = new Vector2(p2.X, p17.Y);
            Vector2 p19 = fun.Polar(p16, pi, l - (Math.Abs(p9.X - p7.X)));
            Vector2 p21 = fun.Polar(p19, pi - pi / 4, (Math.Abs(p9.X - p7.X)) / Math.Cos(pi / 4));
            Vector2 p22 = fun.Polar(p21, pi / 2, bl2);
            Vector2 p23 = fun.Polar(p22, 0, Math.Abs(p11.X - p13.X));
            Vector2 p25 = fun.Polar(p17, 0, L - l - l1 - (Math.Abs(p16.X - p17.X)) * 2);
            Vector2 p26 = fun.Polar(p25, -pi / 4, fun.CalDistance(p16, p17));
            Vector2 p27 = fun.Polar(p26, 0, l1 - (dj) * (Math.Cos(pi / 4)));
            Vector2 p28 = fun.Polar(p27, pi / 4, dj);
            Vector2 p0_ = fun.Polar(p0, 0, L + l);


            Vector2 p24 = fun.mirrorpoint(p17, p0, p0_);
            Vector2 p29 = fun.mirrorpoint(p25, p0, p0_);
            Vector2 p30 = fun.mirrorpoint(p26, p0, p0_);
            Vector2 p31 = fun.mirrorpoint(p27, p0, p0_);
            Vector2 p32 = fun.mirrorpoint(p28, p0, p0_);


            Line line100 = new Line(p6, p16);
            dxf.AddEntity(line100);

            if (l1 != 0)
            {
                LwPolyline poly1 = new LwPolyline();
                poly1.Vertexes.Add(new LwPolylineVertex(p0));
                poly1.Vertexes.Add(new LwPolylineVertex(p11));
                poly1.Vertexes[1].Bulge = Math.Tan((29 * pi / 180) / 4);
                poly1.Vertexes.Add(new LwPolylineVertex(p12));
                poly1.Vertexes[2].Bulge = Math.Tan((141 * pi / 180) / 4);
                poly1.Vertexes.Add(new LwPolylineVertex(p12_));
                poly1.Vertexes[3].Bulge = Math.Tan((29 * pi / 180) / 4);
                poly1.Vertexes.Add(new LwPolylineVertex(p10));
                poly1.Vertexes.Add(new LwPolylineVertex(p11));
                poly1.Vertexes.Add(new LwPolylineVertex(p9));
                poly1.Vertexes.Add(new LwPolylineVertex(p7));
                poly1.Vertexes.Add(new LwPolylineVertex(p6));
                poly1.Vertexes.Add(new LwPolylineVertex(p5));
                poly1.Vertexes.Add(new LwPolylineVertex(p4));
                poly1.Vertexes.Add(new LwPolylineVertex(p8));
                poly1.Vertexes.Add(new LwPolylineVertex(p9));
                poly1.Vertexes.Add(new LwPolylineVertex(p3));
                poly1.Vertexes.Add(new LwPolylineVertex(p4));
                poly1.Vertexes.Add(new LwPolylineVertex(p3));
                poly1.Vertexes[15].Bulge = -Math.Tan((pi / 3 - 5.0 * pi / 180) / 4);
                poly1.Vertexes.Add(new LwPolylineVertex(p2));
                poly1.Vertexes.Add(new LwPolylineVertex(p1));
                poly1.Vertexes.Add(new LwPolylineVertex(p14));
                poly1.Vertexes.Add(new LwPolylineVertex(p22));
                poly1.Vertexes.Add(new LwPolylineVertex(p11));
                poly1.Vertexes.Add(new LwPolylineVertex(p13));
                poly1.Vertexes.Add(new LwPolylineVertex(p23));
                poly1.Vertexes.Add(new LwPolylineVertex(p22));
                poly1.Vertexes.Add(new LwPolylineVertex(p21));
                poly1.Vertexes.Add(new LwPolylineVertex(p19));
                poly1.Vertexes.Add(new LwPolylineVertex(p16));
                poly1.Vertexes.Add(new LwPolylineVertex(p17));
                poly1.Vertexes.Add(new LwPolylineVertex(p18));
                poly1.Vertexes[28].Bulge = Math.Tan((pi / 3) / 4);
                poly1.Vertexes.Add(new LwPolylineVertex(p15));
                poly1.Vertexes.Add(new LwPolylineVertex(p21));
                poly1.Vertexes.Add(new LwPolylineVertex(p15));
                poly1.Vertexes.Add(new LwPolylineVertex(p14));
                poly1.Vertexes.Add(new LwPolylineVertex(p1));
                poly1.Vertexes.Add(new LwPolylineVertex(p0));
                // dxf.AddEntity(poly1);
                fun.PolyFill(dxf, poly1, 0.2, contour);



                LwPolyline poly2 = new LwPolyline();
                poly2.Vertexes.Add(new LwPolylineVertex(p17));
                poly2.Vertexes.Add(new LwPolylineVertex(p25));
                poly2.Vertexes.Add(new LwPolylineVertex(p26));
                poly2.Vertexes.Add(new LwPolylineVertex(p30));
                poly2.Vertexes.Add(new LwPolylineVertex(p29));
                poly2.Vertexes.Add(new LwPolylineVertex(p24));
                poly2.Vertexes.Add(new LwPolylineVertex(p5));
                poly2.Vertexes.Add(new LwPolylineVertex(p24));
                poly2.Vertexes.Add(new LwPolylineVertex(p29));
                poly2.Vertexes.Add(new LwPolylineVertex(p30));
                poly2.Vertexes.Add(new LwPolylineVertex(p31));
                poly2.Vertexes.Add(new LwPolylineVertex(p27));
                poly2.Vertexes.Add(new LwPolylineVertex(p26));
                poly2.Vertexes.Add(new LwPolylineVertex(p27));
                poly2.Vertexes.Add(new LwPolylineVertex(p28));
                poly2.Vertexes.Add(new LwPolylineVertex(p32));
                poly2.Vertexes.Add(new LwPolylineVertex(p31));
                // dxf.AddEntity(poly2);
                fun.PolyFill(dxf, poly2, 0.2, contour);


                fun.dimrot1(dxf, p21, p28, 180, l1 / 2, 2, 1.2, 1.6, 0.9, "  L=" + L, "", "");
                fun.dimrot1(dxf, p21, p16, 180, l1 / 4, 2, 1.2, 1.6, 0.9, "  l=" + l, "", "");
                fun.dimrot1(dxf, p26, p28, 180, l1 / 4, 2, 1.2, 1.6, 0.9, "  l1=" + l1, "", "");
                fun.dimrot1(dxf, p27, p31, -90, d1 * 2, 2, 1.2, 1.6, 0.9, "  d1=" + d1, "", "");
                fun.dimrot1(dxf, p7, p19, 90, l1 / 2, 2, 1.2, 1.6, 0.9, "  d=" + d, "", "");


                //中心线
                Line line1 = new Line(p0, fun.Polar(p0, 0, 2 * l1 + 5));
                line1.Linetype = Linetype.DashDot;
                line1.Lineweight = Lineweight.W25;
                line1.Layer = center;
                dxf.AddEntity(line1);
                Line line2 = new Line(p0, fun.Polar(p0, pi, l + 5));
                line2.Linetype = Linetype.DashDot;
                line2.Lineweight = Lineweight.W25;
                line2.Layer = center;
                dxf.AddEntity(line2);


            }

            else
            {
                LwPolyline poly1 = new LwPolyline();
                poly1.Vertexes.Add(new LwPolylineVertex(p0));
                poly1.Vertexes.Add(new LwPolylineVertex(p11));
                poly1.Vertexes[1].Bulge = Math.Tan((29 * pi / 180) / 4);
                poly1.Vertexes.Add(new LwPolylineVertex(p12));
                poly1.Vertexes[2].Bulge = Math.Tan((141 * pi / 180) / 4);
                poly1.Vertexes.Add(new LwPolylineVertex(p12_));
                poly1.Vertexes[3].Bulge = Math.Tan((29 * pi / 180) / 4);
                poly1.Vertexes.Add(new LwPolylineVertex(p10));
                poly1.Vertexes.Add(new LwPolylineVertex(p11));
                poly1.Vertexes.Add(new LwPolylineVertex(p9));
                poly1.Vertexes.Add(new LwPolylineVertex(p7));
                poly1.Vertexes.Add(new LwPolylineVertex(p6));
                poly1.Vertexes.Add(new LwPolylineVertex(p5));
                poly1.Vertexes.Add(new LwPolylineVertex(p24));
                poly1.Vertexes.Add(new LwPolylineVertex(p5));
                poly1.Vertexes.Add(new LwPolylineVertex(p4));
                poly1.Vertexes.Add(new LwPolylineVertex(p8));
                poly1.Vertexes.Add(new LwPolylineVertex(p9));
                poly1.Vertexes.Add(new LwPolylineVertex(p3));
                poly1.Vertexes.Add(new LwPolylineVertex(p4));
                poly1.Vertexes.Add(new LwPolylineVertex(p3));
                poly1.Vertexes[17].Bulge = -Math.Tan((pi / 3 - 5.0 * pi / 180) / 4);
                poly1.Vertexes.Add(new LwPolylineVertex(p2));
                poly1.Vertexes.Add(new LwPolylineVertex(p1));
                poly1.Vertexes.Add(new LwPolylineVertex(p14));
                poly1.Vertexes.Add(new LwPolylineVertex(p22));
                poly1.Vertexes.Add(new LwPolylineVertex(p11));
                poly1.Vertexes.Add(new LwPolylineVertex(p13));
                poly1.Vertexes.Add(new LwPolylineVertex(p23));
                poly1.Vertexes.Add(new LwPolylineVertex(p22));
                poly1.Vertexes.Add(new LwPolylineVertex(p21));
                poly1.Vertexes.Add(new LwPolylineVertex(p19));
                poly1.Vertexes.Add(new LwPolylineVertex(p16));
                poly1.Vertexes.Add(new LwPolylineVertex(p17));
                poly1.Vertexes.Add(new LwPolylineVertex(p18));
                poly1.Vertexes[30].Bulge = Math.Tan((pi / 3) / 4);
                poly1.Vertexes.Add(new LwPolylineVertex(p15));
                poly1.Vertexes.Add(new LwPolylineVertex(p21));
                poly1.Vertexes.Add(new LwPolylineVertex(p15));
                poly1.Vertexes.Add(new LwPolylineVertex(p14));
                poly1.Vertexes.Add(new LwPolylineVertex(p1));
                poly1.Vertexes.Add(new LwPolylineVertex(p0));
                // dxf.AddEntity(poly1);
                fun.PolyFill(dxf, poly1, 0.2, contour);

                Milling_cutter.Morse_tapershank(dxf, fun.Polar(p0, 0, Math.Abs(p6.X - p24.X)), d, L, l, msyz, 0);


                fun.dimrot1(dxf, p21, p16, 180, L / 8, 2, 1.2, 1.6, 0.9, "  l=" + l, "", "");
                fun.dimrot1(dxf, p7, p19, 90, L / 4, 2, 1.2, 1.6, 0.9, "  d=" + d, "", "");
                fun.dimrot1(dxf, p21, fun.Polar(p21, 0, L + 0.76), 180, L / 6, 2, 1.2, 1.6, 0.9, "  L=" + L, "", "");

                //中心线
                Line line1 = new Line(p0, fun.Polar(p0, 0, L + 5));
                line1.Linetype = Linetype.DashDot;
                line1.Lineweight = Lineweight.W25;
                line1.Layer = center;
                dxf.AddEntity(line1);
                Line line2 = new Line(p0, fun.Polar(p0, pi, l + 5));
                line2.Linetype = Linetype.DashDot;
                line2.Lineweight = Lineweight.W25;
                line2.Layer = center;
                dxf.AddEntity(line2);
            }

            double isframe = Convert.ToInt32(data["isframe"]);
            String isframe_chose = Convert.ToString(data["isframe_chose"]);
            if (isframe == 1)
            {
                if (isframe_chose.Equals("0"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA0X(dxf, new Vector2(p0.X - 1189 / 2.0, p0.Y + 841 / 2.0), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }

                if (isframe_chose.Equals("1"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA1X(dxf, new Vector2(p0.X - 841 / 2.0, p0.Y + 594 / 2.0), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }

                if (isframe_chose.Equals("2"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA2X(dxf, new Vector2(p0.X - 594 / 2.0, p0.Y + 420 / 2.0), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }

                if (isframe_chose.Equals("3"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA3X(dxf, new Vector2(p0.X - 420 / 2.0, p0.Y + 297 / 2.0), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }

                if (isframe_chose.Equals("4X"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA4X(dxf, new Vector2(p0.X - 297 / 2.0, p0.Y + 210 / 2.0 - 10 * 2.26), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }

                if (isframe_chose.Equals("4Y"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA4Y(dxf, new Vector2(p0.X - 210 / 2.0, p0.Y + 297 / 2.0), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }
            }

            fun.SetLayer(dxf);
            fun.SetByLayer(dxf);





            dxf.DrawingVariables.AcadVer = DxfVersion.AutoCad2007;
            dxf.Save(path);

           
        }

        public static void Kshapedknifehandle(Dictionary<string, Object> data)    //K型刀柄
        {
            DxfDocument dxf = new DxfDocument();
            dxf.Layers["0"].Lineweight = Lineweight.W25;
            Layer contour = new Layer("contour");//轮廓层
            Layer dimensioning = new Layer("dimensioning");//尺寸层
            Layer refin = new Layer("refin");//基准线/内轮廓/虚线
            Layer center = new Layer("center");//中心线
            Layer textlayer = new Layer("textlayer");//文本层
            Layer hatching = new Layer("hatching");//填充层
            Layer additionalline = new Layer("additionalline");//附加线
            Layer cutting = new Layer("cutting");//切削层
            fun.SetLayer(dxf);


            //标注样式
            //箭头样式
            DimensionStyle dimensionStyle = fun.CreateDimStyle();
            dimensionStyle.ArrowSize = 3.5;
            dimensionStyle.ExtLineExtend = 0.6;//标注延长线长度/2
            dimensionStyle.DimArrow1 = DimensionArrowhead.Closedfilled;
            dimensionStyle.DimArrow2 = DimensionArrowhead.Closedfilled;
            dimensionStyle.TextHeight = 3.5;
            double offset = 10;
            /*
            string path = Convert.ToString(data["path"]);
            double pi = Math.PI;
            double γε = 0.8;
            double d1 = 16;
            double l1 = 150;
            double l2 = 9.52;
            double a = 2.2;
            double f = 11;
            double an = 11;
            double γf = 0;
            double dmin = 20;
            double sb = 3.18;
            double dj = 1;
            double h1 = d1 / 2;
            double eper = 90;
            double eper_ = eper * pi / 180;//刀偏角
            double pj = 75;
            double pj_ = pj * pi / 180;
            double pj_1 = pj_ - pi / 2;
            double cw = 1;
            */
            /*
            string path = Convert.ToString(data["path"]);
            double pi = Math.PI;
            double γε = 0.8;
            double d1 = 20;
            double l1 = 180;
            double l2 = 9.52;
            double a = 2.2;
            double f = 13;
            double an = 11;
            double γf = 0;
            double dmin = 25;
            double sb = 3.18;
            double dj = 1;
            double h1 = d1 / 2;
            double eper = 75;
            double eper_ = eper * pi / 180;//刀偏角
            */

            double scale = Convert.ToDouble(data["scale"]); //放大系数
            string path = Convert.ToString(data["path"]);
            double pi = Math.PI;
            double γε = Convert.ToDouble(data["re"])* scale;
            double d1 = Convert.ToDouble(data["dcon"]) * scale;
            double l1 = Convert.ToDouble(data["lf"]) * scale;
            double l2 = Convert.ToDouble(data["l"]) * scale;
            double a = Convert.ToDouble(data["wfa"]) * scale;
            double f = Convert.ToDouble(data["wf"]) * scale;
            double an = Convert.ToDouble(data["an"]) * scale;
            double γf = 0;
            double dmin = Convert.ToDouble(data["dmin"]) * scale;
            double sb = Convert.ToDouble(data["s"]) * scale;
            double dj = Convert.ToDouble(data["dj"]);//倒角
            double h1 = d1 / 2;
            double eper = Convert.ToDouble(data["eper"]);
            double eper_ = eper * pi / 180;//刀尖角
            double pj = Convert.ToDouble(data["pj"]);//刀偏角
            double cw = Convert.ToDouble(data["cw"]) * scale;
            double pj_ = pj * pi / 180;
            double pj_1 = pj_ - pi / 2;

            /*
            string path = Convert.ToString(data["path"]);
            double pi = Math.PI;
            double γε = 0.8;
            double d1 = 12;
            double l1 = 125;
            double l2 = 7.75;
            double a = 2.2;
            double f = 9;
            double an = 11;
            double γf = 0;
            double dmin = 16;
            double sb = 2.38;
            double dj = 1;
            double h1 = d1 / 2;
            double eper = 55;
            double eper_ = eper * pi / 180;//刀偏角
            double pj = 107.5;
            double pj_ = pj * pi / 180;
            double pj_1 = pj_ - pi / 2;
            double cw = 2;
            */
            if (l2 == 15.88 || l2 == 19.05)
            {
                γε = 1.2;
            }
            else if (l2 == 7.75)
            {
                γε = 0.4;
            }

            else
            {
                γε = 0.8;
            }
            if (an == 7)
            {
                γf = 0;
            }
            else if (an == 0)
            {
                γf = -6;
            }
            else
            {
                γf = 11;
            }




            Vector2 p0 = new Vector2(0, 0);
            Vector2 p1 = fun.Polar(p0, pi, d1 / 2 - Math.Cos(pi / 4) * dj);
            Vector2 p2 = fun.Polar(p1, pi + pi / 4, dj);
            //Vector2 p3 = fun.Polar(p2, pi / -2, l1*2.0/3.0 + p2.Y);
            Vector2 p3 = new Vector2(-d1 / 2, (l1 - 2 * l2) * -1);
            //System.Diagnostics.Debug.WriteLine(l1 * 2.0 / 3.0);
            // System.Diagnostics.Debug.WriteLine(l1 * 2.0 / 3.0+p2.Y );
            Vector2 pzx1 = new Vector2(0, 0);
            Vector2 pzx2 = new Vector2(0, -l1);
            Vector2 p4;
            Vector2 p5;
            Vector2 p6;
            Vector2 p61;
            Vector2 p62;
            Vector2 p7;
            Vector2 p71;
            Vector2 p72;
            Vector2 p8;
            Vector2 p81;
            Vector2 p82;
            Vector2 p9;
            Vector2 p91;
            Vector2 p92;
            Vector2 p10;
            Vector2 p11;
            Vector2 p12;
            Vector2 p13;
            Vector2 p14;
            Vector2 p15;
            Vector2 p131;
            Vector2 p132;
            double psy1;
            Vector2 p13d;
            if (cw == 1)
            {
                p4 = fun.Polar(p3, -pi / 2, l1 - d1 / 4 - (l1 - 2 * l2));
                p5 = fun.Polar(p4, pi / -4, d1 / 4 * Math.Sqrt(2));
                p6 = fun.Polar(p5, 0, f + d1 / 4);
                p61 = fun.Polar(p6, pi / 2 + (eper_ - pj_), γε);
                p62 = fun.Polar(p6, pi + (eper_ - pj_), γε);
                p7 = fun.Polar(p6, pi + (eper_ - pj_), l2);
                p71 = fun.Polar(p7, (eper_ - pj_), γε);
                p72 = fun.Polar(p7, pi / 2 + (eper_ - pj_), γε);
                p8 = fun.Polar(p7, pi / 2 + (pi / 2 - pj_), l2);
                p81 = fun.Polar(p8, -pj_, γε);
                p82 = fun.Polar(p8, (pi / 2 - pj_), γε);
                p9 = fun.Polar(p8, pi / 2 - pj_, l2);
                p91 = fun.Polar(p9, pi + (pi / 2 - pj_), γε);
                p92 = fun.Polar(p9, -pj_, γε);
                p11 = fun.Polar(p6, pi, (l2 / Math.Cos(pi / 2 - pj_)));
                p10 = new Vector2(0, -l1);

                p12 = fun.Polar(p9, pi / 2 + (pi / 2 - pj_), (p9.X - d1 / 2) / Math.Cos(pj));
                p13 = fun.Polar(p3, 0, d1);
                p13d = fun.Polar(p3, 0, d1);
            }

            else
            {
                p4 = fun.Polar(p3, -pi / 2, l1 - ((Math.Tan(pj_1) * (f + d1 / 4) + d1 / 4)) - (l1 - 2 * l2));
                p5 = fun.Polar(p4, pi / -4, d1 / 4 / Math.Cos(pi / 4));
                p11 = fun.Polar(p5, -pj_1, ((f + d1 / 4) / Math.Cos(pj_1)) - (γε + 0.3 + l2));
                // System.Diagnostics.Debug.WriteLine(((f + d1 / 4) / Math.Cos(pj_)) - ((γε + 0.3) + Math.Sin(pj_1) * l2));
                p7 = fun.Polar(p11, -pj_1 - pi / 4, (γε + 0.3) / Math.Cos(pi / 4));
                p71 = fun.Polar(p7, -pj_1, γε);
                p72 = fun.Polar(p7, pi - pj_1 - eper_, γε);
                p6 = fun.Polar(p7, -pj_1, l2);
                p61 = fun.Polar(p6, pi - pj_1 - eper_, γε);
                p62 = fun.Polar(p6, pi - pj_1, γε);
                p8 = fun.Polar(p7, pi - pj_1 - eper_, l2);
                p81 = fun.Polar(p8, -eper_ - pj_1, γε);
                p82 = fun.Polar(p8, -pj_1, γε);
                p9 = fun.Polar(p8, -pj_1, l2);
                p91 = fun.Polar(p9, -pj_1 - pi, γε);
                p92 = fun.Polar(p9, -pj_1 - eper_, γε);
                p10 = fun.Polar(p6, pi - pj_1 - eper_, (γε + 0.3) * 3);
                p13 = fun.Polar(p3, 0, d1);
                psy1 = fun.CalAngle(p10, p13);
                p12 = fun.Polar(p13, psy1 - pi, γε);
                p13d = fun.Polar(p13, pi, γε);

            }


            p14 = fun.mirrorpoint(p1, pzx1, pzx2);
            p15 = fun.mirrorpoint(p2, pzx1, pzx2);
            //左视图
            Vector2 p16 = new Vector2(-(4 * d1), -l1 / 2);

            Vector2 p17 = fun.Polar(p16, 0, dmin / 2);
            Vector2 p16_ = fun.Polar(p17, pi, f);
            Vector2 p18 = fun.Polar(p17, pi + γf * pi / 180, (f + h1) * Math.Cos(γf * pi / 180));
            Vector2 p19 = fun.Polar(p17, pi / -2 - an * pi / 180, sb);
            Vector2 p21 = fun.Polar(p17, pi + γf * pi / 180, l2);
            Vector2 p20 = fun.Polar(p21, pi / -2, sb);
            //System.Diagnostics.Debug.WriteLine(pi / -2 + an * pi / 180);
            // System.Diagnostics.Debug.WriteLine(100001000);
            Vector2 p22 = fun.Polar(p16_, 0, h1);
            Vector2 p23 = fun.Polar(p16_, pi / -2, h1);
            Arc arc2 = fun.DrawArc(p23, p16_, p22);
            Vector2 p22p = fun.getPointForArcandLine(p17, fun.Polar(p18, γf * pi / 180, 2), p16_, arc2);
            Vector2 p24 = fun.Polar(p17, pi + γf * pi / 180, (f + (f - l2)) / Math.Cos(γf * pi / 180));
            Vector2 p25 = fun.Polar(p24, pi / -2, sb);
            Arc arc1 = fun.DrawArc(fun.Polar(p16_, pi, h1), p16_, fun.Polar(p16_, pi / -2, h1));
            // Vector2 p25=fun .Polar (p24,pi,((dmin / 2 + (dmin / 2 - l2))*Math .Sin (γf))+)
            Vector2 p26 = fun.getPointForArcandLine(p25, fun.Polar(p25, pi / -2, h1 + 5), p16_, arc1);

            //刨视图
            Vector2 p27;
            Vector2 p28;
            Vector2 p29;
            Vector2 p30;
            Vector2 p31;
            Vector2 p32;
            Vector2 p33;
            Vector2 p34;
            Vector2 p35;
            Vector2 p36;
            Vector2 p37;

            p27 = new Vector2(3 * d1, -l1 / 2);
            p28 = fun.Polar(p27, pi + γf * pi / 180, sb);
            p29 = fun.Polar(p28, pi / -2 + γf * pi / 180, l2);
            p30 = fun.Polar(p29, 0 + γf * pi / 180, sb);
            p31 = fun.Polar(p29, pi + γf * pi / 180, sb);
            p32 = fun.Polar(p27, pi / 2 + γf * pi / 180, sb * 1.5);
            p33 = fun.Polar(p32, pi + γf * pi / 180, fun.CalDistance(p30, p31) / 2);
            p34 = fun.Polar(p33, pi + γf * pi / 180, fun.CalDistance(p30, p31) / 2);
            p35 = fun.Polar(p34, pi / -2 + γf * pi / 180, fun.CalDistance(p32, p30) / 4);
            p36 = fun.Polar(p35, pi / -2 + γf * pi / 180, fun.CalDistance(p32, p30) / 4);
            p37 = fun.Polar(p36, pi / -2 + γf * pi / 180, fun.CalDistance(p32, p30) / 4);

            //中心點
            Vector2 p38 = fun.Polar(pzx1, pi / 2, 3);
            Vector2 p39 = fun.Polar(pzx2, pi / -2, 3);

            Vector2 p40 = fun.Polar(p16, pi, dmin / 2 + 3);
            Vector2 p41 = fun.Polar(p16, 0, dmin / 2 + 3);
            Vector2 p42 = fun.Polar(p16, pi / 2, dmin / 4);
            Vector2 p43 = fun.Polar(p16, pi / -2, dmin / 4);
            Vector2 p44 = fun.Polar(p16_, pi / 2, dmin / 2 + 3);
            Vector2 p45 = fun.Polar(p16_, pi / -2, dmin / 2 + 3);

            Vector2 p46 = fun.Polar(p30, pi / 2, l2 + sb * 2);


            //局抛an=0箭头
            Vector2 p47 = fun.Polar(p30, pi / -2, l2 + 3);
            Vector2 p48 = fun.Polar(p47, 10 * pi / 180, 1.6 / Math.Cos(10));
            Vector2 p49 = fun.Polar(p47, -10 * pi / 180, 1.6 / Math.Cos(10));

            Vector2 p50 = fun.Polar(p47, pi - 10 * pi / 180, 1.6 / Math.Cos(10));
            Vector2 p51 = fun.Polar(p47, pi + 10 * pi / 180, 1.6 / Math.Cos(10));
            Vector2 p52 = fun.Polar(fun.Polar(p47, 0, 1.6), 10 * pi / 180, sb);
            Vector2 p53 = fun.Polar(fun.Polar(p47, pi, 1.6), pi - 10 * pi / 180, l2);
            Vector2 p54 = fun.Polar(p47, 0, fun.CalDistance(p48, p49) / 2);

            //an=0时的仰视图
            Vector2 p55 = fun.Polar(p17, 0, dmin);
            Vector2 p56 = fun.Polar(p55, pi, 3);
            Vector2 p57 = fun.Polar(p56, 100 * pi / 180, 1.6 / Math.Cos(10));
            Vector2 p58 = fun.Polar(p56, 80 * pi / 180, 1.6 / Math.Cos(10));

            Vector2 p59 = fun.Polar(p56, -80 * pi / 180, 1.6 / Math.Cos(10));
            Vector2 p60 = fun.Polar(p56, -100 * pi / 180, 1.6 / Math.Cos(10));

            Vector2 p100 = fun.Polar(fun.Polar(p56, pi / 2, 1.6), 100 * pi / 180, dmin / 2);
            Vector2 p101 = fun.Polar(fun.Polar(p56, pi / -2, 1.6), -100 * pi / 180, dmin / 4);

            Vector2 p102 = fun.Polar(p6, pi / -2 - pj_, l2 / 2);
            Vector2 p103 = fun.Polar(p102, pi / -2 - pj_ - pi / 2, l2 * (1.0 / 4.0));
            Vector2 p104 = fun.Polar(p102, -pj_, 2 * l2);
            Vector2 p105 = fun.Polar(p102, -pi - pj_, 2 * l2);
            Vector2 p106 = fun.Polar(p105, -pi - pj_, l2);

            Vector2 p107 = fun.Polar(p104, -pi - pj_, 1.0 / 10 * l2);
            Vector2 p108 = fun.Polar(p107, (pi / -2 - pj_) + (10 * pi / 180), 1.6 / Math.Cos(10 * pi / 180));
            Vector2 p109 = fun.Polar(p107, (pi / -2 - pj_) - (10 * pi / 180), 1.6 / Math.Cos(10 * pi / 180));
            Vector2 p110 = fun.Polar(p109, -pj_, fun.CalDistance(p108, p109) / 2.0);
            Vector2 p111 = fun.Polar(p110, pi / -2 - pj_, l2 * 2.0 / 3.0);
            Vector2 p114 = fun.Polar(p106, -pj_, 1.0 / 4.0 * l2);
            Vector2 p115 = fun.Polar(p114, (-pi / 2 - pj_) + (10 * pi / 180), 1.6 / Math.Cos(10 * pi / 180));
            Vector2 p116 = fun.Polar(p114, (-pi / 2 - pj_) - (10 * pi / 180), 1.6 / Math.Cos(10 * pi / 180));
            Vector2 p117 = fun.Polar(p116, -pj_, fun.CalDistance(p108, p109) / 2.0);
            Vector2 p118 = fun.Polar(p117, pi / -2 - pj_, l2);



            Vector2 p119;

            if (cw == 1)
            {
                p119 = fun.Polar(p10, pi / -2, d1 * 3 + 5);
            }
            else
            {
                p119 = fun.Polar(pzx2, pi / -2, d1 * 3 + 5);
            }
            Vector2 p120 = fun.Polar(p119, pi / -2 + 10 * pi / 180, 1.6 / Math.Cos(10 * pi / 180));
            Vector2 p121 = fun.Polar(p119, pi / -2 - 10 * pi / 180, 1.6 / Math.Cos(10 * pi / 180));

            Vector2 p122 = fun.Polar(p120, pi, fun.CalDistance(p120, p121) / 2.0);
            Vector2 p123 = fun.Polar(p122, pi / -2, d1 / 2);

            Vector2 p124 = fun.Polar(p6, pi / 4, 1.6);
            Vector2 p125 = fun.Polar(p6, pi / 4 + (10 * pi / 180), 1.6 / Math.Cos(10 * pi / 180));
            Vector2 p126 = fun.Polar(p6, pi / 4 - (10 * pi / 180), 1.6 / Math.Cos(10 * pi / 180));
            Vector2 p127 = fun.Polar(p124, pi / 4, l2 * 2);
            Vector2 p128 = fun.Polar(p127, pi / 4 - pi, 1.6);

            if (cw == 1)
            {

                LwPolyline poly1 = new LwPolyline();
                poly1.Vertexes.Add(new LwPolylineVertex(p0));
                poly1.Vertexes.Add(new LwPolylineVertex(p1));
                poly1.Vertexes.Add(new LwPolylineVertex(p2));
                poly1.Vertexes.Add(new LwPolylineVertex(p4));
                poly1.Vertexes.Add(new LwPolylineVertex(p5));
                poly1.Vertexes.Add(new LwPolylineVertex(p11));
                poly1.Vertexes.Add(new LwPolylineVertex(p72));
                poly1.Vertexes[6].Bulge = Math.Tan((pi / 2) / 4);
                poly1.Vertexes.Add(new LwPolylineVertex(p71));
                poly1.Vertexes.Add(new LwPolylineVertex(p62));
                poly1.Vertexes[8].Bulge = Math.Tan((pi / 2) / 4);
                poly1.Vertexes.Add(new LwPolylineVertex(p61));
                poly1.Vertexes.Add(new LwPolylineVertex(p12));
                poly1.Vertexes.Add(new LwPolylineVertex(p15));
                poly1.Vertexes.Add(new LwPolylineVertex(p14));
                poly1.Vertexes.Add(new LwPolylineVertex(p0));
                poly1.Vertexes.Add(new LwPolylineVertex(p1));
                poly1.Vertexes.Add(new LwPolylineVertex(p2));
                poly1.Vertexes.Add(new LwPolylineVertex(p15));
                fun.PolyFill(dxf, poly1, 0.5, contour);


                LwPolyline poly2 = new LwPolyline();
                poly2.Vertexes.Add(new LwPolylineVertex(p71));
                poly2.Vertexes[0].Bulge = -Math.Tan((pi / 2) / 4);
                poly2.Vertexes.Add(new LwPolylineVertex(p72));
                poly2.Vertexes.Add(new LwPolylineVertex(p81));
                poly2.Vertexes[2].Bulge = -Math.Tan((pi / 2) / 4);
                poly2.Vertexes.Add(new LwPolylineVertex(p82));
                poly2.Vertexes.Add(new LwPolylineVertex(p91));
                poly2.Vertexes[4].Bulge = -Math.Tan((pi / 2) / 4);
                poly2.Vertexes.Add(new LwPolylineVertex(p92));
                poly2.Vertexes.Add(new LwPolylineVertex(p61));
                poly2.Vertexes[6].Bulge = -Math.Tan((pi / 2) / 4);
                poly2.Vertexes.Add(new LwPolylineVertex(p62));
                poly2.Vertexes.Add(new LwPolylineVertex(p71));
                fun.PolyFill(dxf, poly2, 0.5, contour);
            }

            else
            {




                LwPolyline poly1 = new LwPolyline();
                poly1.Vertexes.Add(new LwPolylineVertex(p0));
                poly1.Vertexes.Add(new LwPolylineVertex(p1));
                poly1.Vertexes.Add(new LwPolylineVertex(p2));
                poly1.Vertexes.Add(new LwPolylineVertex(p3));
                poly1.Vertexes.Add(new LwPolylineVertex(p4));
                poly1.Vertexes.Add(new LwPolylineVertex(p5));
                poly1.Vertexes.Add(new LwPolylineVertex(p11));
                fun.PolyFill(dxf, poly1, 0.5, contour);

                LwPolyline poly100 = new LwPolyline();
                poly100.Vertexes.Add(new LwPolylineVertex(p10));
                poly100.Vertexes.Add(new LwPolylineVertex(p13));
                poly100.Vertexes.Add(new LwPolylineVertex(p15));
                poly100.Vertexes.Add(new LwPolylineVertex(p14));
                poly100.Vertexes.Add(new LwPolylineVertex(p1));
                poly100.Vertexes.Add(new LwPolylineVertex(p2));
                poly100.Vertexes.Add(new LwPolylineVertex(p15));
                fun.PolyFill(dxf, poly100, 0.5, contour);

                LwPolyline poly2 = new LwPolyline();
                poly2.Vertexes.Add(new LwPolylineVertex(p71));
                poly2.Vertexes[0].Bulge = -Math.Tan((eper_) / 4);
                poly2.Vertexes.Add(new LwPolylineVertex(p72));
                poly2.Vertexes.Add(new LwPolylineVertex(p81));
                poly2.Vertexes[2].Bulge = -Math.Tan((pi - eper_) / 4);
                poly2.Vertexes.Add(new LwPolylineVertex(p82));
                poly2.Vertexes.Add(new LwPolylineVertex(p91));
                poly2.Vertexes[4].Bulge = -Math.Tan((eper_) / 4);
                poly2.Vertexes.Add(new LwPolylineVertex(p92));
                poly2.Vertexes.Add(new LwPolylineVertex(p61));
                poly2.Vertexes[6].Bulge = -Math.Tan((pi - eper_) / 4);
                poly2.Vertexes.Add(new LwPolylineVertex(p62));
                poly2.Vertexes.Add(new LwPolylineVertex(p71));
                fun.PolyFill(dxf, poly2, 0.5, contour);


                LwPolyline poly22 = new LwPolyline();
                poly22.Vertexes.Add(new LwPolylineVertex(p10));
                poly22.Vertexes.Add(new LwPolylineVertex(p12));
                poly22.Vertexes[1].Bulge = Math.Tan((pi / 2) / 4);
                poly22.Vertexes.Add(new LwPolylineVertex(p13d));
                fun.PolyFill(dxf, poly22, 0.5, contour);


            }



            LwPolyline poly3 = new LwPolyline();
            poly3.Vertexes.Add(new LwPolylineVertex(p3));
            poly3.Vertexes[0].Bulge = -Math.Tan((pi / 3) / 4);
            poly3.Vertexes.Add(new LwPolylineVertex(p13));
            poly3.Vertexes.Add(new LwPolylineVertex(p3));
            fun.PolyFill(dxf, poly3, 0.5, contour);


            //仰视图

            LwPolyline poly4 = new LwPolyline();
            poly4.Vertexes.Add(new LwPolylineVertex(p17));
            poly4.Vertexes.Add(new LwPolylineVertex(p19));
            poly4.Vertexes.Add(new LwPolylineVertex(p20));
            poly4.Vertexes.Add(new LwPolylineVertex(p21));
            poly4.Vertexes.Add(new LwPolylineVertex(p17));
            poly4.Vertexes.Add(new LwPolylineVertex(p18));
            poly4.Vertexes.Add(new LwPolylineVertex(p24));
            poly4.Vertexes.Add(new LwPolylineVertex(p26));
            fun.PolyFill(dxf, poly4, 0.5, contour);

            if (cw == 1)
            {
                LwPolyline poly5 = new LwPolyline();
                poly5.Vertexes.Add(new LwPolylineVertex(p25));
                poly5.Vertexes[0].Bulge = Math.Tan((pi / 2) / 4);
                poly5.Vertexes.Add(new LwPolylineVertex(p20));
                poly5.Vertexes.Add(new LwPolylineVertex(fun.Polar(p19, pi + γf * pi / 180, (fun.CalDistance(p22p, p17)) / 2)));
                poly5.Vertexes[2].Bulge = -Math.Tan((50 * pi / 180) / 4);
                poly5.Vertexes.Add(new LwPolylineVertex(p23));
                fun.PolyFill(dxf, poly5, 0.5, contour);
            }
            else
            {
                LwPolyline poly5 = new LwPolyline();

                poly5.Vertexes.Add(new LwPolylineVertex(p20));
                poly5.Vertexes.Add(new LwPolylineVertex(fun.Polar(p19, pi + γf * pi / 180, (fun.CalDistance(p22p, p17)) / 2)));
                poly5.Vertexes[1].Bulge = -Math.Tan((50 * pi / 180) / 4);
                poly5.Vertexes.Add(new LwPolylineVertex(p23));
                fun.PolyFill(dxf, poly5, 0.5, contour);

            }

            LwPolyline poly6 = new LwPolyline();
            poly6.Vertexes.Add(new LwPolylineVertex(p32));
            poly6.Vertexes.Add(new LwPolylineVertex(p27));
            poly6.Vertexes.Add(new LwPolylineVertex(p28));
            poly6.Vertexes.Add(new LwPolylineVertex(p29));
            poly6.Vertexes.Add(new LwPolylineVertex(p31));
            poly6.Vertexes[4].Bulge = Math.Tan((pi / 6) / 4);
            poly6.Vertexes.Add(new LwPolylineVertex(p37));
            poly6.Vertexes[5].Bulge = -Math.Tan((pi / 6) / 4);
            poly6.Vertexes.Add(new LwPolylineVertex(p36));
            poly6.Vertexes[6].Bulge = Math.Tan((30 * pi / 180) / 4);
            poly6.Vertexes.Add(new LwPolylineVertex(p35));
            poly6.Vertexes[7].Bulge = Math.Tan((30 * pi / 180) / -4);
            poly6.Vertexes.Add(new LwPolylineVertex(p34));
            poly6.Vertexes[8].Bulge = Math.Tan((30 * pi / 180) / -4);
            poly6.Vertexes.Add(new LwPolylineVertex(p33));
            poly6.Vertexes[9].Bulge = Math.Tan((pi / 6) / 4);
            poly6.Vertexes.Add(new LwPolylineVertex(p32));


            poly6.Lineweight = Lineweight.W35;
            poly6.Layer = additionalline;
            dxf.AddEntity(poly6);


            String[] htype1 = new String[100];
            Line[] hline1 = new Line[100];
            Arc[] harc1 = new Arc[100];
            int hnumst1 = poly6.Explode().Count;  //记录爆炸后，线段有多少
            for (int i = 0; i < hnumst1; i++)
            {
                htype1[i] = poly6.Explode()[i].Type.ToString();    //将所有元素的类型记录成一个数组
                if (htype1[i] == "Line")
                {
                    hline1[i] = (Line)poly6.Explode()[i];
                }
                if (htype1[i] == "Arc")
                {
                    harc1[i] = (Arc)poly6.Explode()[i];
                }
            }
            fun.hatchsub1(dxf, htype1, hnumst1, 45, 5, hline1, harc1, hatching);


            LwPolyline poly7 = new LwPolyline();
            poly7.Vertexes.Add(new LwPolylineVertex(p32));
            poly7.Vertexes.Add(new LwPolylineVertex(p27));
            poly7.Vertexes.Add(new LwPolylineVertex(p30));
            poly7.Vertexes.Add(new LwPolylineVertex(p29));
            poly7.Vertexes.Add(new LwPolylineVertex(p28));
            poly7.Vertexes.Add(new LwPolylineVertex(p27));
            fun.PolyFill(dxf, poly7, 0.5, contour);

            String[] htype2 = new String[100];
            Line[] hline2 = new Line[100];
            Arc[] harc2 = new Arc[100];
            int hnumst2 = poly7.Explode().Count;  //记录爆炸后，线段有多少
            for (int i = 0; i < hnumst2; i++)
            {
                htype2[i] = poly7.Explode()[i].Type.ToString();    //将所有元素的类型记录成一个数组
                if (htype2[i] == "Line")
                {
                    hline2[i] = (Line)poly7.Explode()[i];
                }
                if (htype2[i] == "Arc")
                {
                    harc2[i] = (Arc)poly7.Explode()[i];
                }
            }
            fun.hatchsub1(dxf, htype2, hnumst2, 135, 5, hline2, harc2, hatching);

            Line line1 = new Line(p38, p39);
            line1.Linetype = Linetype.DashDot;
            line1.Lineweight = Lineweight.W25;
            line1.Layer = center;
            dxf.AddEntity(line1);

            Line line2 = new Line(p40, p41);
            line2.Linetype = Linetype.DashDot;
            line2.Lineweight = Lineweight.W25;
            line2.Layer = center;
            dxf.AddEntity(line2);

            Line line3 = new Line(p42, p43);
            line3.Linetype = Linetype.DashDot;
            line3.Lineweight = Lineweight.W25;
            line3.Layer = center;
            dxf.AddEntity(line3);

            Line line4 = new Line(p44, p45);
            line4.Linetype = Linetype.DashDot;
            line4.Lineweight = Lineweight.W25;
            line4.Layer = center;
            dxf.AddEntity(line4);

            Line line5 = new Line(p30, p46);
            line5.Linetype = Linetype.DashDot;
            line5.Lineweight = Lineweight.W25;
            line5.Layer = center;
            dxf.AddEntity(line5);




            Circle circlex = new Circle(new Vector3(p16.X, p16.Y, 0), dmin / 2);//圆
            circlex.Linetype = Linetype.Dashed;
            circlex.Lineweight = netDxf.Lineweight.W25;
            circlex.Layer = refin;
            dxf.AddEntity(circlex);

            Arc arc3 = fun.DrawArc(p22p, p16_, p23);
            fun.drawBArc(dxf, arc3, 0.5, contour);


            if (cw == 1)
            {
                fun.dimrot1(dxf, p6, p7, -90, d1 / 2, 2, 1.2, 1.6, 0.9, "  a=" + a/ scale, "", "");
                fun.dimrot1(dxf, p7, p6, -180 + (90 - 75), d1 * 2, 2, 1.2, 1.6, 0.9, "  l2=" + l2 / scale, "", "");
            }

            else
            {
                fun.dimrot1(dxf, p7, p6, 180 - (pj - 90), d1 * 2, 2, 1.2, 1.6, 0.9, "  l2=" + l2 / scale, "", "");
            }

            fun.dimrot1(dxf, p2, p15, 0, d1 / 2, 2, 1.2, 1.6, 0.9, "  d1=" + d1 / scale, "", "");
            fun.dimrot1(dxf, p14, p6, -90, d1 / 2, 2, 1.2, 1.6, 0.9, "  l1=" + l1 / scale, "", "");

            fun.dimrot1(dxf, pzx2, p6, 180, d1 * 3, 2, 1.2, 1.6, 0.9, "  f=" + f / scale, "", "");


            fun.dimrot1(dxf, p2, p15, 0, d1 / 2, 2, 1.2, 1.6, 0.9, "  d1=" + d1 / scale, "", "");

            fun.dimrot1(dxf, p17, p23, 90, dmin * 2, 2, 1.2, 1.6, 0.9, "  h1=" + h1 / scale, "", "");
            fun.dimrot1(dxf, p17, fun.Polar(p17, pi, dmin), 180, d1, 2, 1.2, 1.6, 0.9, "  dmin=" + dmin / scale, "", "");
            fun.dimrot1(dxf, p17, p19, -90 + γf, dmin * 1.5, 2, 1.2, 1.6, 0.9, "  sb=" + sb / scale, "", "");
            fun.jdbz2(dxf, new Line(p6, p7), new Line(p6, fun.Polar(p6, pi / -2, l2)), d1, 1.6, 1.2, 0.9, "pj=" + pj + "°" + "±1°", "", "");
            fun.jdbz2(dxf, new Line(p6, fun.Polar(p6, (pi - pj_1 - eper_) - pi, l2)), new Line(p6, fun.Polar(p6, -pj_1, 0.1)), d1 / 2, 1.6, 1.2, 0.9, "eper=" + eper + "°", "", "");

            Line line10 = new Line(p103, p104);
            line10.Linetype = Linetype.DashDot;
            line10.Lineweight = Lineweight.W25;
            line10.Layer = dimensioning;
            dxf.AddEntity(line10);

            Line line11 = new Line(p105, p106);
            line11.Linetype = Linetype.DashDot;
            line11.Lineweight = Lineweight.W25;
            line11.Layer = dimensioning;
            dxf.AddEntity(line11);

            Line line12 = new Line(p122, p123);
            line12.Lineweight = Lineweight.W25;
            line12.Layer = dimensioning;
            dxf.AddEntity(line12);

            Line line13 = new Line(p110, p111);
            line13.Lineweight = Lineweight.W25;
            line13.Layer = dimensioning;
            dxf.AddEntity(line13);

            Line line14 = new Line(p117, p118);
            line14.Lineweight = Lineweight.W25;
            line14.Layer = dimensioning;
            dxf.AddEntity(line14);

            Line line15 = new Line(p124, p128);
            line15.Lineweight = Lineweight.W25;
            line15.Layer = dimensioning;
            dxf.AddEntity(line15);

            Solid entity5 = new Solid(p107, p108, p109);
            dxf.AddEntity(entity5);
            Solid entity6 = new Solid(p114, p115, p116);
            dxf.AddEntity(entity6);
            Solid entity7 = new Solid(p119, p120, p121);
            dxf.AddEntity(entity7);
            Solid entity8 = new Solid(p6, p125, p126);
            dxf.AddEntity(entity8);
            if (cw == 1)
            {
                Text txt2 = new Text("A", fun.Polar(p104, -pj_, 1.6), 1.6, 15);
                dxf.AddEntity(txt2);
                Text txt3 = new Text("A", fun.Polar(p117, pi / 2, 2), 1.6, 15);
                dxf.AddEntity(txt3);
            }
            else
            {
                Text txt2 = new Text("A", fun.Polar(p104, -pj_, 1.6), 1.6, -30);
                dxf.AddEntity(txt2);
                Text txt3 = new Text("A", fun.Polar(p117, pi / 2, 2), 1.6, -30);
                dxf.AddEntity(txt3);
            }
            Text txt4 = new Text("X", fun.Polar(p123, -pi / 2, 1.6), 1.6, 0);
            dxf.AddEntity(txt4);
            Text txt5 = new Text("γε", p128, 1.6, 45);
            dxf.AddEntity(txt5);
            Text txt6 = new Text("X", fun.Polar(p44, pi / 2, 4), 1.6, 0);
            dxf.AddEntity(txt6);
            Text txt7 = new Text("A-A", p46, 1.6, 0);
            dxf.AddEntity(txt7);
            Text txt8 = new Text("an=" + an + "°", fun.Polar(p46, pi + (pi / 6) / 2.0, 8 * sb), 1.6, 0);
            dxf.AddEntity(txt8);


            if (an == 7)
            {
                Line line6 = new Line(p30, fun.Polar(p30, pi / -2, l2 + 5));
                line6.Lineweight = Lineweight.W25;
                line6.Layer = refin;
                dxf.AddEntity(line6);

                LwPolyline poly9 = new LwPolyline();
                poly9.Vertexes.Add(new LwPolylineVertex(p53));
                poly9.Vertexes[0].Bulge = Math.Tan((10 * pi / 180) / 4);
                poly9.Vertexes.Add(new LwPolylineVertex(fun.Polar(p47, pi, 1.6)));
                poly9.Vertexes.Add(new LwPolylineVertex(fun.Polar(p47, 0, 1.6)));
                poly9.Vertexes[2].Bulge = Math.Tan((10 * pi / 180) / 4);
                poly9.Vertexes.Add(new LwPolylineVertex(p52));
                poly9.Lineweight = Lineweight.W25;
                poly9.Layer = dimensioning;

                dxf.AddEntity(poly9);

                Solid entity1 = new Solid(p47, p48, p49);
                dxf.AddEntity(entity1);
                Solid entity2 = new Solid(p47, p50, p51);
                dxf.AddEntity(entity2);
                Text txt = new Text("0°" + "±1°", fun.Polar(p53, pi / 2, 0.1), 1.6, 0.9);
                dxf.AddEntity(txt);




                Line line9 = new Line(p17, p55);
                line9.Lineweight = Lineweight.W25;
                line9.Layer = refin;
                dxf.AddEntity(line9);

                LwPolyline poly8 = new LwPolyline();
                poly8.Vertexes.Add(new LwPolylineVertex(p100));
                poly8.Vertexes[0].Bulge = -Math.Tan((10 * pi / 180) / 4);
                poly8.Vertexes.Add(new LwPolylineVertex(fun.Polar(p56, pi / 2, 1.6)));
                poly8.Vertexes.Add(new LwPolylineVertex(fun.Polar(p56, pi / -2, 1.6)));
                poly8.Vertexes[2].Bulge = -Math.Tan((10 * pi / 180) / 4);
                poly8.Vertexes.Add(new LwPolylineVertex(p101));
                poly8.Lineweight = Lineweight.W25;
                poly8.Layer = dimensioning;

                dxf.AddEntity(poly8);






                Solid entity3 = new Solid(p56, p57, p58);
                dxf.AddEntity(entity3);
                Solid entity4 = new Solid(p56, p59, p60);
                dxf.AddEntity(entity4);
                Text txt1 = new Text("γf=" + "γf°" + "±1°", p100, 1.6, 90);
                dxf.AddEntity(txt1);













            }

            else
            {
                fun.jdbz2(dxf, new Line(p30, fun.Polar(p30, pi / -2, 0.1)), new Line(p30, fun.Polar(p30, pi / -2 + γf * pi / 180, 0.1)), dmin / 2, 1.6, 0.5, 0.9, "γf=" + γf + "°" + "±1°", "", "");
                fun.jdbz2(dxf, new Line(p17, fun.Polar(p17, 0, 0.1)), new Line(p17, fun.Polar(p17, γf * pi / 180, 0.1)), dmin / 2, 1.6, 0.5, 0.9, "γf=" + γf + "°", "", "");

            }


            double isframe = Convert.ToInt32(data["isframe"]);
            String isframe_chose = Convert.ToString(data["isframe_chose"]);
            if (isframe == 1)
            {
                if (isframe_chose.Equals("0"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA0X(dxf, new Vector2(p0.X - 1189 / 2.0, p0.Y + 841 / 2.0), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }

                if (isframe_chose.Equals("1"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA1X(dxf, new Vector2(p0.X - 841 / 2.0, p0.Y + 594 / 2.0), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }

                if (isframe_chose.Equals("2"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA2X(dxf, new Vector2(p0.X - 594 / 2.0, p0.Y + 420 / 2.0), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }

                if (isframe_chose.Equals("3"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA3X(dxf, new Vector2(p0.X - 420 / 2.0, p0.Y + 297 / 2.0), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }

                if (isframe_chose.Equals("4X"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA4X(dxf, new Vector2(p0.X - 297 / 2.0, p0.Y + 210 / 2.0 - 10 * 2.26), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }

                if (isframe_chose.Equals("4Y"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA4Y(dxf, new Vector2(p0.X - 210 / 2.0, p0.Y + 297 / 2.0), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }
            }




            fun.SetLayer(dxf);
            fun.SetByLayer(dxf);

            dxf.DrawingVariables.AcadVer = DxfVersion.AutoCad2007;
            dxf.Save(path);



            
        }

        public static void Morsebridgereamer(Dictionary<string, Object> data)    //莫氏锥柄机用桥梁铰刀
        {
            DxfDocument dxf = new DxfDocument();
            dxf.Layers["0"].Lineweight = Lineweight.W25;
            Layer contour = new Layer("contour");//轮廓层
            Layer dimensioning = new Layer("dimensioning");//尺寸层
            Layer refin = new Layer("refin");//基准线/内轮廓/虚线
            Layer center = new Layer("center");//中心线
            Layer textlayer = new Layer("textlayer");//文本层
            Layer hatching = new Layer("hatching");//填充层
            Layer additionalline = new Layer("additionalline");//附加线
            Layer cutting = new Layer("cutting");//切削层
            fun.SetLayer(dxf);


            /*
            string path = Convert.ToString(data["path"]);
            double pi = Math.PI;
            double d = 6.4;
            double L = 151;
            double l = 75;
            double l1 = 30;
            double msyz = 1;
            double bl2= d/5.2989;
            */

            string path = Convert.ToString(data["path"]);
            double pi = Math.PI;
            double d = Convert.ToDouble(data["dc"]); ;
            double L = Convert.ToDouble(data["oal"]); ;
            double l = Convert.ToDouble(data["lu"]); ;
            double l1 = Convert.ToDouble(data["ldc"]); ;
            double msyz = Convert.ToDouble(data["msyz"]);







            Vector2 p0 = new Vector2(0, 0);
            Vector2 p1 = fun.Polar(p0, pi / 2, ((3.27 / 4.04 * d) / 2) * (2.34736992 / 5.05591990));
            Vector2 p2 = fun.Polar(p0, -68 * pi / 180, ((3.27 / 4.04 * d) / 2) * (2.34736992 / 5.05591990));
            Vector2 p3 = fun.Polar(p0, pi / 2, ((3.27 / 4.04 * d) / 2));

            Vector2 p4 = fun.Polar(fun.Polar(p0, pi, ((Math.Sqrt(2)) / 2)), pi / 2, d / 2);
            Vector2 p5 = fun.mirrorpoint(p3, p0, fun.Polar(p0, pi, 100));
            Vector2 p6 = fun.mirrorpoint(p4, p0, fun.Polar(p0, pi, 100));
            Vector2 p7 = fun.Polar(p0, pi, (l - l1) * (12.29021797 / 45));
            Vector2 p8 = fun.Polar(p7, pi, (l - l1) * (5.10152105 / 45));
            Vector2 p9 = fun.Polar(p0, pi + 5 * pi / 180, (l - l1) * ((39.82640580 / Math.Cos(5 * pi / 180)) / 45));
            Vector2 p10 = fun.Polar(p0, pi + 8.555 * pi / 180, (l - l1) * ((20.22743837 / Math.Cos(8.555 * pi / 180)) / 45));

            Vector2 p11 = fun.Polar(p6, pi, (l - l1) * (2.47508045 / 45));
            Vector2 p12 = fun.Polar(p5, pi / 2, ((3.27 / 4.04 * d)) * (1.16025224 / 5.18019802));

            Vector2 p13 = fun.Polar(p3, pi, (l - l1) * (7.93781486 / 45));
            Vector2 p14 = fun.Polar(p8, pi, (l - l1) * (13.88189377 / 45));
            Vector2 p15 = fun.Polar(p14, pi, (l - l1) * (4.20180157 / 45));
            Vector2 p16 = fun.Polar(p0, pi + 3 * pi / 180, (l - l1) * ((58.26859930 / Math.Cos(3 * pi / 180)) / 45));

            Vector2 p17 = fun.Polar(p13, pi + 2 * pi / 180, (l - l1) * ((24.34703338 / Math.Cos(2 * pi / 180)) / 45));
            Vector2 p18 = fun.Polar(p9, pi - 0.48884718, l * ((11.68012152 / 75)));
            Vector2 p19 = fun.Polar(p0, pi, l * (55.64156828 / 75));
            Vector2 p20 = fun.Polar(p0, pi + 0.06277425, l * (74.37609787 / 75));
            Vector2 p21 = fun.Polar(fun.Polar(p0, pi, l), pi / -2, 4.50717622);

            Vector2 p23 = fun.Polar(p19, 0, l * (2.91781309 / 75));
            Vector2 p24 = fun.Polar(p18, 0, l * (4.18081308 / 75));


            Vector2 p18sy = fun.Polar(p18, pi, 300);
            Vector2 p21sy = fun.Polar(p21, pi / 2, 100);





            Vector2 p25 = fun.Inters(p18, p18sy, p21, p21sy);
            Vector2 p26 = fun.Polar(p21, pi / 2, Math.Abs(p21.Y / 2));
            Vector2 p27 = fun.Polar(p25, 0.09861838, l * (7.83434028 / 75));
            Vector2 p28 = fun.Polar(p0, pi, l * (70.08514284 / 75));

            Arc arc1 = fun.DrawArc3(p9, p10, p7);
            Arc arc2 = fun.DrawArc3(p10, p11, p2);
            // dxf.AddEntity(arc2);
            // dxf.AddEntity(arc1);
            Arc arc3 = fun.DrawArc3(p17, p18, p19);
            //dxf.AddEntity(arc3);

            Arc arc5 = fun.DrawArc3(p21, p16, p23);
            // dxf.AddEntity(arc5);
            Arc arc6 = fun.DrawArc3(p17, p24, p23);
            //  dxf.AddEntity(arc6);

            Arc arc7 = fun.DrawArc3(p18, p27, p26);
            // dxf.AddEntity(arc7);
            Arc arc8 = fun.DrawArc3(p17, p24, p23);
            // dxf.AddEntity(arc8);
            Arc arc9 = fun.DrawArc3(p18, p28, p20);
            //dxf.AddEntity(arc9);

            fun.drawBArc(dxf, arc1, 0.2, contour);
            fun.drawBArc(dxf, arc2, 0.2, contour);
            fun.drawBArc(dxf, arc3, 0.2, contour);
            fun.drawBArc(dxf, arc5, 0.2, contour);
            fun.drawBArc(dxf, arc6, 0.2, contour);
            fun.drawBArc(dxf, arc7, 0.2, contour);
            fun.drawBArc(dxf, arc8, 0.2, contour);
            fun.drawBArc(dxf, arc9, 0.2, contour);





            LwPolyline poly3 = new LwPolyline();
            poly3.Vertexes.Add(new LwPolylineVertex(p1));
            poly3.Vertexes.Add(new LwPolylineVertex(p3));
            poly3.Vertexes.Add(new LwPolylineVertex(p4));
            poly3.Vertexes[2].Bulge = Math.Tan((21 * pi / 180) / 4);
            poly3.Vertexes.Add(new LwPolylineVertex(p8));
            poly3.Vertexes[3].Bulge = -Math.Tan((45 * pi / 180) / 4);
            poly3.Vertexes.Add(new LwPolylineVertex(p9));
            //dxf.AddEntity(poly3); 
            fun.PolyFill(dxf, poly3, 0.2, contour);

            LwPolyline poly1 = new LwPolyline();
            poly1.Vertexes.Add(new LwPolylineVertex(p7));
            poly1.Vertexes[0].Bulge = -Math.Tan((15 * pi / 180) / 4);
            poly1.Vertexes.Add(new LwPolylineVertex(p1));
            poly1.Vertexes[1].Bulge = -Math.Tan((130 * pi / 180) / 4);
            poly1.Vertexes.Add(new LwPolylineVertex(p2));
            poly1.Vertexes[2].Bulge = -Math.Tan((5 * pi / 180) / 4);
            poly1.Vertexes.Add(new LwPolylineVertex(p12));
            poly1.Vertexes.Add(new LwPolylineVertex(p5));
            poly1.Vertexes.Add(new LwPolylineVertex(p6));
            poly1.Vertexes.Add(new LwPolylineVertex(p11));
            poly1.Vertexes.Add(new LwPolylineVertex(p6));
            poly1.Vertexes.Add(new LwPolylineVertex(p5));
            poly1.Vertexes.Add(new LwPolylineVertex(p12));
            poly1.Vertexes[9].Bulge = Math.Tan((5 * pi / 180) / 4);
            poly1.Vertexes.Add(new LwPolylineVertex(p2));

            //dxf.AddEntity(poly1);

            fun.PolyFill(dxf, poly1, 0.2, contour);


            LwPolyline poly2 = new LwPolyline();
            poly2.Vertexes.Add(new LwPolylineVertex(p13));
            poly2.Vertexes[0].Bulge = Math.Tan((53 * pi / 180) / 4);
            poly2.Vertexes.Add(new LwPolylineVertex(p15));
            poly2.Vertexes[1].Bulge = -Math.Tan((57 * pi / 180) / 4);
            poly2.Vertexes.Add(new LwPolylineVertex(p16));
            poly2.Vertexes[2].Bulge = Math.Tan((36 * pi / 180) / 4);
            poly2.Vertexes.Add(new LwPolylineVertex(p9));
            poly2.Vertexes[3].Bulge = Math.Tan((18 * pi / 180) / 4);
            poly2.Vertexes.Add(new LwPolylineVertex(p14));
            poly2.Vertexes[4].Bulge = -Math.Tan((58 * pi / 180) / 4);
            poly2.Vertexes.Add(new LwPolylineVertex(p13));
            //dxf.AddEntity(poly2);
            fun.PolyFill(dxf, poly2, 0.2, contour);

            LwPolyline poly4 = new LwPolyline();
            poly4.Vertexes.Add(new LwPolylineVertex(p19));
            poly4.Vertexes[0].Bulge = -Math.Tan((0.90694642) / 4);
            poly4.Vertexes.Add(new LwPolylineVertex(p21));
            //dxf.AddEntity(poly4);
            fun.PolyFill(dxf, poly4, 0.2, contour);

            LwPolyline poly5 = new LwPolyline();
            poly5.Vertexes.Add(new LwPolylineVertex(p21));
            poly5.Vertexes.Add(new LwPolylineVertex(p25));
            poly5.Vertexes[1].Bulge = -Math.Tan((1.01788635) / 4);
            poly5.Vertexes.Add(new LwPolylineVertex(p27));
            //dxf.AddEntity(poly5);
            fun.PolyFill(dxf, poly5, 0.2, contour);



            Milling_cutter.Morse_tapershank(dxf, p0, d, L, l, msyz, 0);



            //标注
            fun.dimrot1(dxf, p21, fun.Polar(fun.Polar(p21, pi / -2, 2), 0, l * (2.25 / 6.0)), 180, l1 / 2, 2, 1.2, 1.6, 0.9, "  l1=" + l1, "", "");
            fun.dimrot1(dxf, p21, p5, 180, l1, 2, 1.2, 1.6, 0.9, "  l=" + l, "", "");
            fun.dimrot1(dxf, p21, fun.Polar(p0, 0, L - l), 180, l1 * 2, 2, 1.2, 1.6, 0.9, "  L=" + L, "", "");


            double isframe = Convert.ToInt32(data["isframe"]);
            String isframe_chose = Convert.ToString(data["isframe_chose"]);
            double scale = Convert.ToDouble(data["scale"]); //放大系数
            if (isframe == 1)
            {
                if (isframe_chose.Equals("0"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA0X(dxf, new Vector2(p0.X - 1189 / 2.0, p0.Y + 841 / 2.0), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }

                if (isframe_chose.Equals("1"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA1X(dxf, new Vector2(p0.X - 841 / 2.0, p0.Y + 594 / 2.0), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }

                if (isframe_chose.Equals("2"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA2X(dxf, new Vector2(p0.X - 594 / 2.0, p0.Y + 420 / 2.0), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }

                if (isframe_chose.Equals("3"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA3X(dxf, new Vector2(p0.X - 420 / 2.0, p0.Y + 297 / 2.0), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }

                if (isframe_chose.Equals("4X"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA4X(dxf, new Vector2(p0.X - 297 / 2.0, p0.Y + 210 / 2.0 - 10 * 2.26), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }

                if (isframe_chose.Equals("4Y"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA4Y(dxf, new Vector2(p0.X - 210 / 2.0, p0.Y + 297 / 2.0), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }
            }



            //Line line1 = new Line(p20, p0);
            // Line line2 = new Line(p0, p5);
            // dxf.AddEntity(line1);
            // dxf.AddEntity(line2);

            fun.SetLayer(dxf);
            fun.SetByLayer(dxf);
            dxf.DrawingVariables.AcadVer = DxfVersion.AutoCad2007;
            dxf.Save(path);


        }
        public static void Lshapedshank(Dictionary<string, Object> data)    //L型刀柄
        {
            DxfDocument dxf = new DxfDocument();
            dxf.Layers["0"].Lineweight = Lineweight.W25;
            Layer contour = new Layer("contour");//轮廓层
            Layer dimensioning = new Layer("dimensioning");//尺寸层
            Layer refin = new Layer("refin");//基准线/内轮廓/虚线
            Layer center = new Layer("center");//中心线
            Layer textlayer = new Layer("textlayer");//文本层
            Layer hatching = new Layer("hatching");//填充层
            Layer additionalline = new Layer("additionalline");//附加线
            Layer cutting = new Layer("cutting");//切削层
            fun.SetLayer(dxf);
            /*
            string path = Convert.ToString(data["path"]);
            double pi = Math.PI;           
            double γε = 0.4;
            double d1 =8;
            double l1 =80;
            double l2 = 6.4;
            double a = 2.2;
            double f = 6;
            double an = 7;
            double γf = 0;
            double dmin = 11;
            double sb =2.38;
            double dj = 1;
            double h1 = d1 / 2;
            double eper = 55;
            double eper_ = eper * pi / 180;//刀偏角
            double c = 0;
            double zm = c;
            double cw = 1;
            double pj = 93;
            double pj_ = (pj * pi / 180) - (pi / 2);
            
            string path = Convert.ToString(data["path"]);
            double pi = Math.PI;
            double cw = 2;
            double γε = 0.8;
            double d1 = 8;
            double l1 = 80;
            double l2 =3.26;
            double a = 2.2;
            double f = 6;
            double an = 7;
            double γf = 0;
            double dmin = 11;
            double sb = 1.98;
            double dj = 1;
            double h1 = d1 / 2;
            double eper = 80;
            double eper_ = eper * pi / 180;//刀偏角
           */

            double scale = Convert.ToDouble(data["scale"]); //放大系数
            string path = Convert.ToString(data["path"]);
            double pi = Math.PI;
            double cw = Convert.ToDouble(data["cw"])* scale;
            double γε = Convert.ToDouble(data["re"]) * scale;
            double d1 = Convert.ToDouble(data["dcon"]) * scale;
            double l1 = Convert.ToDouble(data["lf"]) * scale;
            double l2 = Convert.ToDouble(data["l"]) * scale;
            double f = Convert.ToDouble(data["wf"]) * scale;
            double an = Convert.ToDouble(data["an"]);
            double γf = 0;
            double dmin = Convert.ToDouble(data["dmin"]) * scale;
            double sb = Convert.ToDouble(data["s"]) * scale;
            double dj = Convert.ToDouble(data["dj"]);
            double h1 = d1 / 2;
            double eper = Convert.ToDouble(data["eper"]);
            double eper_ = eper * pi / 180;//刀偏角
            double pj = Convert.ToDouble(data["pj"]);
            double pj_ = (pj * pi / 180) - (pi / 2);




            if (cw == 1)
            {

                if (l2 == 19.3 || l2 == 16.1)
                {
                    γε = 1.2;
                }

                else if (l2 == 12.9 || l2 == 9.7)
                {
                    γε = 0.8;
                }
                else
                {
                    γε = 0.4;
                }
            }

            else
            {
                if (l2 == 6.52 || l2 == 4.34)
                {
                    γε = 0.4;
                }
                else if (l2 == 8.69)
                {
                    γε = 0.8;
                }
                else
                {
                    if (l2 < 4.34)
                    {
                        γε = 0.4;
                    }



                }
            }


            if (an == 7)
            {
                γf = 0;
            }
            else
            {
                γf = -6;
            }


            System.Diagnostics.Debug.WriteLine(γε);
            System.Diagnostics.Debug.WriteLine(100000);
            Vector2 p0 = new Vector2(0, 0);
            Vector2 p1 = fun.Polar(p0, pi, d1 / 2 - Math.Cos(pi / 4) * dj);
            Vector2 p2 = fun.Polar(p1, pi + pi / 4, dj);
            //Vector2 p3 = fun.Polar(p2, pi / -2, l1*2.0/3.0 + p2.Y);
            Vector2 p3 = new Vector2(-d1 / 2, (l1 - 3 * l2) * -1);
            Vector2 p4 = fun.Polar(p3, pi / -2, l1 - (f + d1 / 2) * Math.Tan(pj_) - (l1 - 3 * l2));

            Vector2 p6;
            Vector2 p61;
            Vector2 p62;
            Vector2 p7;
            Vector2 p71;
            Vector2 p72;
            Vector2 p8;
            Vector2 p81;
            Vector2 p82;
            Vector2 p85;
            Vector2 p851;
            Vector2 p852;
            Vector2 p9;
            Vector2 p91;
            Vector2 p92;
            Vector2 p86;
            Vector2 p861;
            Vector2 p862;




            if (cw == 1)
            {
                p7 = fun.Polar(p4, -pj_, (f + d1 / 2) / Math.Cos(pj_) - l2);
                p71 = fun.Polar(p7, -pj_, γε);
                p72 = fun.Polar(p7, pi - (eper_ + pj_), γε);
                p6 = fun.Polar(p7, -pj_, l2);
                p61 = fun.Polar(p6, pi - (eper_ + pj_), γε);
                p62 = fun.Polar(p6, pi - pj_, γε);
                p8 = fun.Polar(p7, pi - (eper_ + pj_), l2);
                p81 = fun.Polar(p8, pi - (eper_ + pj_) - pi, γε);
                p82 = fun.Polar(p8, -pj_, γε);
                p9 = fun.Polar(p6, pi - (eper_ + pj_), l2);
                p91 = fun.Polar(p9, pi - pj_, γε);
                p92 = fun.Polar(p9, pi - (eper_ + pj_) - pi, γε);
                p851 = fun.Polar(p7, pi - (eper_ + pj_), l2);
                p852 = fun.Polar(p7, pi - (eper_ + pj_), l2);
                p86 = fun.Polar(p7, pi - (eper_ + pj_), l2);
                p861 = fun.Polar(p7, pi - (eper_ + pj_), l2);
                p862 = fun.Polar(p7, pi - (eper_ + pj_), l2);
            }
            else
            {
                p6 = fun.Polar(p4, -pj_, (f + d1 / 2) / Math.Cos(pj_));
                p61 = fun.Polar(p6, pi - eper_ - pj_, γε);
                p62 = fun.Polar(p6, pi - pj_, γε);
                p7 = fun.Polar(p6, pi - pj_, l2);
                p71 = fun.Polar(p7, -pj_, γε);
                p72 = fun.Polar(p7, eper_ * 2 - pj_, γε);
                p8 = fun.Polar(p7, eper_ * 2 - pj_, l2);
                p81 = fun.Polar(p8, eper_ * 2 - pj_ - pi, γε);
                p82 = fun.Polar(p8, eper_ * 3 - pj_ - pi, γε);
                p9 = fun.Polar(p6, pi - eper_ - pj_, l2);
                p91 = fun.Polar(p9, -3 * eper_ - pj_, γε);
                p92 = fun.Polar(p9, -eper_ - pj_, γε);
                p85 = fun.Polar(p9, -3 * eper_ - pj_, l2);
                p851 = fun.Polar(p85, -3 * eper_ - pj_ - pi - eper_, γε);
                p852 = fun.Polar(p85, -3 * eper_ - pj_ - pi, γε);
                p86 = fun.Polar(p8, eper_ * 3 - pj_ - pi, l2);
                p861 = fun.Polar(p86, eper_ * 3 - pj_ - 2 * pi, γε);
                p862 = fun.Polar(p86, eper_ * 5 - pj_ - 2 * pi, γε);
            }




            Vector2 p10 = fun.Polar(p6, pi, f);

            Vector2 p13 = fun.Polar(p3, 0, d1);
            Vector2 p14 = fun.mirrorpoint(p1, p0, p10);
            Vector2 p15 = fun.mirrorpoint(p2, p0, p10);

            //左视图
            Vector2 p16 = new Vector2(-4 * d1, -l1 / 2);
            Vector2 p17 = fun.Polar(p16, 0, dmin / 2);
            Vector2 p16_ = fun.Polar(p17, pi, f);
            Vector2 p18 = fun.Polar(p17, pi + γf * pi / 180, (f + h1) * Math.Cos(γf * pi / 180));
            Vector2 p19 = fun.Polar(p17, pi / -2 - an * pi / 180, sb);
            Vector2 p21 = fun.Polar(p17, pi + γf * pi / 180, l2);
            Vector2 p20 = fun.Polar(p21, pi / -2 + an * pi / 180, sb);
            //System.Diagnostics.Debug.WriteLine(pi / -2 + an * pi / 180);
            // System.Diagnostics.Debug.WriteLine(100001000);
            Vector2 p22 = fun.Polar(p16_, 0, h1);
            Vector2 p23 = fun.Polar(p16_, pi / -2, h1);
            Arc arc2 = fun.DrawArc(p23, p16_, p22);
            Vector2 p22p = fun.getPointForArcandLine(p17, fun.Polar(p18, γf * pi / 180, 2), p16_, arc2);
            Vector2 p24 = fun.Polar(p17, pi + γf * pi / 180, (f + (f - l2)) / Math.Cos(γf * pi / 180));
            Vector2 p25 = fun.Polar(p24, pi / -2, sb);
            Arc arc1 = fun.DrawArc(fun.Polar(p16, pi, h1), p16, fun.Polar(p16, pi / -2, h1));
            // Vector2 p25=fun .Polar (p24,pi,((dmin / 2 + (dmin / 2 - l2))*Math .Sin (γf))+)
            Vector2 p26 = fun.getPointForArcandLine(p25, fun.Polar(p25, pi / -2, h1 + 5), p16, arc1);

            //刨视图
            Vector2 p27;
            Vector2 p28;
            Vector2 p29;
            Vector2 p30;
            Vector2 p31;
            Vector2 p32;
            Vector2 p33;
            Vector2 p34;
            Vector2 p35;
            Vector2 p36;
            Vector2 p37;
            Vector2 p331;
            p27 = new Vector2(4 * d1, -l1 / 2);
            p28 = fun.Polar(p27, pi + γf * pi / 180, sb);
            p29 = fun.Polar(p28, pi / -2 + γf * pi / 180, l2);
            p30 = fun.Polar(p29, 0 + γf * pi / 180, sb);
            p331 = fun.Polar(p29, pi / 2, 1);
            p31 = fun.Polar(p331, pi + γf * pi / 180, sb);
            p32 = fun.Polar(p27, pi / 2 + γf * pi / 180, sb * 1.5);
            p33 = fun.Polar(p32, pi + γf * pi / 180, fun.CalDistance(p30, p31) / 2);
            p34 = fun.Polar(p33, pi + γf * pi / 180, fun.CalDistance(p30, p31) / 2);
            p35 = fun.Polar(p34, pi / -2 + γf * pi / 180, fun.CalDistance(p32, p30) / 4);
            p36 = fun.Polar(p35, pi / -2 + γf * pi / 180, fun.CalDistance(p32, p30) / 4);
            p37 = fun.Polar(p36, pi / -2 + γf * pi / 180, fun.CalDistance(p32, p30) / 4);

            //中心點
            Vector2 p38 = fun.Polar(p10, pi / 2, l1 + 3);
            Vector2 p39 = fun.Polar(p10, pi / -2, 3);

            Vector2 p40 = fun.Polar(p16, pi, dmin / 2 + 3);
            Vector2 p41 = fun.Polar(p16, 0, dmin / 2 + 3);
            Vector2 p42 = fun.Polar(p16, pi / 2, dmin / 4);
            Vector2 p43 = fun.Polar(p16, pi / -2, dmin / 4);
            Vector2 p44 = fun.Polar(p16_, pi / 2, dmin / 2 + 3);
            Vector2 p45 = fun.Polar(p16_, pi / -2, dmin / 2 + 3);

            Vector2 p46 = fun.Polar(p30, pi / 2, l2 + sb * 2);


            //局抛an=0箭头
            Vector2 p47 = fun.Polar(p30, pi / -2, l2 + 3);
            Vector2 p48 = fun.Polar(p47, 10 * pi / 180, 1.6 / Math.Cos(10));
            Vector2 p49 = fun.Polar(p47, -10 * pi / 180, 1.6 / Math.Cos(10));

            Vector2 p50 = fun.Polar(p47, pi - 10 * pi / 180, 1.6 / Math.Cos(10));
            Vector2 p51 = fun.Polar(p47, pi + 10 * pi / 180, 1.6 / Math.Cos(10));
            Vector2 p52 = fun.Polar(fun.Polar(p47, 0, 1.6), 10 * pi / 180, sb);
            Vector2 p53 = fun.Polar(fun.Polar(p47, pi, 1.6), pi - 10 * pi / 180, l2);
            Vector2 p54 = fun.Polar(p47, 0, fun.CalDistance(p48, p49) / 2);

            //an=0时的仰视图
            Vector2 p55 = fun.Polar(p17, 0, dmin);
            Vector2 p56 = fun.Polar(p55, pi, 3);
            Vector2 p57 = fun.Polar(p56, 100 * pi / 180, 1.6 / Math.Cos(10));
            Vector2 p58 = fun.Polar(p56, 80 * pi / 180, 1.6 / Math.Cos(10));

            Vector2 p59 = fun.Polar(p56, -80 * pi / 180, 1.6 / Math.Cos(10));
            Vector2 p60 = fun.Polar(p56, -100 * pi / 180, 1.6 / Math.Cos(10));

            Vector2 p100 = fun.Polar(fun.Polar(p56, pi / 2, 1.6), 100 * pi / 180, dmin / 2);
            Vector2 p101 = fun.Polar(fun.Polar(p56, pi / -2, 1.6), -100 * pi / 180, dmin / 4);

            Vector2 p102 = fun.Polar(p6, pi - 5 * pi / 180, l2 / 2);
            Vector2 p103 = fun.Polar(p102, eper_ - 5 * pi / 180, l2 * (1.0 / 6.0));
            Vector2 p104 = fun.Polar(p102, -95 * pi / 180, 2 * l2);
            Vector2 p105 = fun.Polar(p102, eper_ + 5 * pi / 180, 2 * l2);
            Vector2 p106 = fun.Polar(p105, eper_ + 5 * pi / 180, l2);

            Vector2 p107 = fun.Polar(p104, eper_ + 5 * pi / 180, 1.0 / 10 * l2 + 2);
            Vector2 p108 = fun.Polar(p107, (pi - 5 * pi / 180) + (10 * pi / 180), 1.6 / Math.Cos(10 * pi / 180));
            Vector2 p109 = fun.Polar(p107, (pi - 5 * pi / 180) - (10 * pi / 180), 1.6 / Math.Cos(10 * pi / 180));
            Vector2 p110 = fun.Polar(p109, eper_ - 5 * pi / 180 - pi, fun.CalDistance(p108, p109) / 2.0);
            Vector2 p111 = fun.Polar(p110, pi - eper_ / 180, l2 * 2.0 / 3.0);
            Vector2 p114 = fun.Polar(p106, eper_ + 5 * pi / 180 - pi, 1.0 / 4.0 * l2);
            Vector2 p115 = fun.Polar(p114, (pi - 5 * pi / 180) + (10 * pi / 180), 1.6 / Math.Cos(10 * pi / 180));
            Vector2 p116 = fun.Polar(p114, (pi - 5 * pi / 180) - (10 * pi / 180), 1.6 / Math.Cos(10 * pi / 180));
            Vector2 p117 = fun.Polar(p116, eper_ + 5 * pi / 180 - pi, fun.CalDistance(p108, p109) / 2.0);
            Vector2 p118 = fun.Polar(p117, pi - 5 * pi / 180, l2);

            Vector2 p119 = fun.Polar(p10, pi / -2, d1 + 3);
            Vector2 p120 = fun.Polar(p119, pi / -2 + 10 * pi / 180, 1.6 / Math.Cos(10 * pi / 180));
            Vector2 p121 = fun.Polar(p119, pi / -2 - 10 * pi / 180, 1.6 / Math.Cos(10 * pi / 180));

            Vector2 p122 = fun.Polar(p120, pi, fun.CalDistance(p120, p121) / 2.0);
            Vector2 p123 = fun.Polar(p122, pi / -2, 5);

            Vector2 p124 = fun.Polar(p6, pi / -4, 1.6);
            Vector2 p125 = fun.Polar(p6, pi / -4 + (10 * pi / 180), 1.6 / Math.Cos(10 * pi / 180));
            Vector2 p126 = fun.Polar(p6, pi / -4 - (10 * pi / 180), 1.6 / Math.Cos(10 * pi / 180));
            Vector2 p127 = fun.Polar(p124, pi / -4, l2 * 4);
            Vector2 p128 = fun.Polar(p127, pi / -4 - pi, 1.6);



            LwPolyline poly1 = new LwPolyline();
            poly1.Vertexes.Add(new LwPolylineVertex(p0));
            poly1.Vertexes.Add(new LwPolylineVertex(p1));
            poly1.Vertexes.Add(new LwPolylineVertex(p2));
            poly1.Vertexes.Add(new LwPolylineVertex(p4));
            poly1.Vertexes.Add(new LwPolylineVertex(p62));
            poly1.Vertexes[4].Bulge = Math.Tan((pi / 2) / 4);
            poly1.Vertexes.Add(new LwPolylineVertex(p61));
            poly1.Vertexes.Add(new LwPolylineVertex(p9));
            poly1.Vertexes.Add(new LwPolylineVertex(p13));
            poly1.Vertexes.Add(new LwPolylineVertex(p15));
            poly1.Vertexes.Add(new LwPolylineVertex(p14));
            poly1.Vertexes.Add(new LwPolylineVertex(p0));
            poly1.Vertexes.Add(new LwPolylineVertex(p1));
            poly1.Vertexes.Add(new LwPolylineVertex(p2));
            poly1.Vertexes.Add(new LwPolylineVertex(p15));
            fun.PolyFill(dxf, poly1, 0.5, contour);


            if (cw == 1)
            {
                LwPolyline poly2 = new LwPolyline();
                poly2.Vertexes.Add(new LwPolylineVertex(p71));
                poly2.Vertexes[0].Bulge = -Math.Tan((pi / 2) / 4);
                poly2.Vertexes.Add(new LwPolylineVertex(p72));
                poly2.Vertexes.Add(new LwPolylineVertex(p81));
                poly2.Vertexes[2].Bulge = -Math.Tan((pi / 2) / 4);
                poly2.Vertexes.Add(new LwPolylineVertex(p82));
                poly2.Vertexes.Add(new LwPolylineVertex(p91));
                poly2.Vertexes[4].Bulge = -Math.Tan((pi / 2) / 4);
                poly2.Vertexes.Add(new LwPolylineVertex(p92));
                poly2.Vertexes.Add(new LwPolylineVertex(p61));
                poly2.Vertexes[6].Bulge = -Math.Tan((pi / 2) / 4);
                poly2.Vertexes.Add(new LwPolylineVertex(p62));
                poly2.Vertexes.Add(new LwPolylineVertex(p71));
                fun.PolyFill(dxf, poly2, 0.5, contour);
            }
            else
            {
                LwPolyline poly2 = new LwPolyline();
                poly2.Vertexes.Add(new LwPolylineVertex(p71));
                poly2.Vertexes[0].Bulge = -Math.Tan((30 * pi / 180) / 4);
                poly2.Vertexes.Add(new LwPolylineVertex(p72));
                poly2.Vertexes.Add(new LwPolylineVertex(p81));
                poly2.Vertexes[2].Bulge = -Math.Tan((80 * pi / 180) / 4);
                poly2.Vertexes.Add(new LwPolylineVertex(p82));
                poly2.Vertexes.Add(new LwPolylineVertex(p861));
                poly2.Vertexes[4].Bulge = -Math.Tan((30 * pi / 180) / 4);
                poly2.Vertexes.Add(new LwPolylineVertex(p862));
                poly2.Vertexes.Add(new LwPolylineVertex(p851));
                poly2.Vertexes[6].Bulge = -Math.Tan((80 * pi / 180) / 4);
                poly2.Vertexes.Add(new LwPolylineVertex(p852));
                poly2.Vertexes.Add(new LwPolylineVertex(p91));
                poly2.Vertexes[8].Bulge = -Math.Tan((30 * pi / 180) / 4);
                poly2.Vertexes.Add(new LwPolylineVertex(p92));
                poly2.Vertexes.Add(new LwPolylineVertex(p61));
                poly2.Vertexes[10].Bulge = -Math.Tan((80 * pi / 180) / 4);
                poly2.Vertexes.Add(new LwPolylineVertex(p62));
                poly2.Vertexes.Add(new LwPolylineVertex(p71));
                fun.PolyFill(dxf, poly2, 0.5, contour);
            }
            LwPolyline poly3 = new LwPolyline();
            poly3.Vertexes.Add(new LwPolylineVertex(p3));
            poly3.Vertexes[0].Bulge = -Math.Tan((pi / 3) / 4);
            poly3.Vertexes.Add(new LwPolylineVertex(p13));
            poly3.Vertexes.Add(new LwPolylineVertex(p3));
            fun.PolyFill(dxf, poly3, 0.5, contour);



            //仰视图

            LwPolyline poly4 = new LwPolyline();
            poly4.Vertexes.Add(new LwPolylineVertex(p17));
            poly4.Vertexes.Add(new LwPolylineVertex(p19));
            poly4.Vertexes.Add(new LwPolylineVertex(p20));
            poly4.Vertexes.Add(new LwPolylineVertex(p21));
            poly4.Vertexes.Add(new LwPolylineVertex(p17));
            poly4.Vertexes.Add(new LwPolylineVertex(p18));
            fun.PolyFill(dxf, poly4, 0.5, contour);


            LwPolyline poly5 = new LwPolyline();
            poly5.Vertexes.Add(new LwPolylineVertex(p20));
            poly5.Vertexes.Add(new LwPolylineVertex(fun.Polar(p19, pi + γf * pi / 180, (fun.CalDistance(p22p, p17)) / 2)));
            poly5.Vertexes[1].Bulge = -Math.Tan((50 * pi / 180) / 4);
            poly5.Vertexes.Add(new LwPolylineVertex(p23));
            fun.PolyFill(dxf, poly5, 0.5, contour);


            LwPolyline poly6 = new LwPolyline();
            poly6.Vertexes.Add(new LwPolylineVertex(p32));
            poly6.Vertexes.Add(new LwPolylineVertex(p27));
            poly6.Vertexes.Add(new LwPolylineVertex(p28));
            poly6.Vertexes.Add(new LwPolylineVertex(p331));

            poly6.Vertexes.Add(new LwPolylineVertex(p31));
            poly6.Vertexes[4].Bulge = Math.Tan((pi / 6) / 4);
            poly6.Vertexes.Add(new LwPolylineVertex(p37));
            poly6.Vertexes[5].Bulge = -Math.Tan((pi / 6) / 4);
            poly6.Vertexes.Add(new LwPolylineVertex(p36));
            poly6.Vertexes[6].Bulge = Math.Tan((30 * pi / 180) / 4);
            poly6.Vertexes.Add(new LwPolylineVertex(p35));
            poly6.Vertexes[7].Bulge = Math.Tan((30 * pi / 180) / -4);
            poly6.Vertexes.Add(new LwPolylineVertex(p34));
            poly6.Vertexes[8].Bulge = Math.Tan((30 * pi / 180) / -4);
            poly6.Vertexes.Add(new LwPolylineVertex(p33));
            poly6.Vertexes[9].Bulge = Math.Tan((pi / 6) / 4);
            poly6.Vertexes.Add(new LwPolylineVertex(p32));


            poly6.Lineweight = Lineweight.W35;
            poly6.Layer = additionalline;
            dxf.AddEntity(poly6);


            String[] htype1 = new String[100];
            Line[] hline1 = new Line[100];
            Arc[] harc1 = new Arc[100];
            int hnumst1 = poly6.Explode().Count;  //记录爆炸后，线段有多少
            for (int i = 0; i < hnumst1; i++)
            {
                htype1[i] = poly6.Explode()[i].Type.ToString();    //将所有元素的类型记录成一个数组
                if (htype1[i] == "Line")
                {
                    hline1[i] = (Line)poly6.Explode()[i];
                }
                if (htype1[i] == "Arc")
                {
                    harc1[i] = (Arc)poly6.Explode()[i];
                }
            }
            fun.hatchsub1(dxf, htype1, hnumst1, 45, 5, hline1, harc1, hatching);


            LwPolyline poly7 = new LwPolyline();
            poly7.Vertexes.Add(new LwPolylineVertex(p32));
            poly7.Vertexes.Add(new LwPolylineVertex(p27));
            poly7.Vertexes.Add(new LwPolylineVertex(p30));
            poly7.Vertexes.Add(new LwPolylineVertex(p29));
            poly7.Vertexes.Add(new LwPolylineVertex(p28));
            poly7.Vertexes.Add(new LwPolylineVertex(p27));
            fun.PolyFill(dxf, poly7, 0.5, contour);

            String[] htype2 = new String[100];
            Line[] hline2 = new Line[100];
            Arc[] harc2 = new Arc[100];
            int hnumst2 = poly7.Explode().Count;  //记录爆炸后，线段有多少
            for (int i = 0; i < hnumst2; i++)
            {
                htype2[i] = poly7.Explode()[i].Type.ToString();    //将所有元素的类型记录成一个数组
                if (htype2[i] == "Line")
                {
                    hline2[i] = (Line)poly7.Explode()[i];
                }
                if (htype2[i] == "Arc")
                {
                    harc2[i] = (Arc)poly7.Explode()[i];
                }
            }
            fun.hatchsub1(dxf, htype2, hnumst2, 135, 5, hline2, harc2, hatching);

            Line line1 = new Line(p38, p39);
            line1.Linetype = Linetype.DashDot;
            line1.Lineweight = Lineweight.W25;
            line1.Layer = center;
            dxf.AddEntity(line1);

            Line line2 = new Line(p40, p41);
            line2.Linetype = Linetype.DashDot;
            line2.Lineweight = Lineweight.W25;
            line2.Layer = center;
            dxf.AddEntity(line2);

            Line line3 = new Line(p42, p43);
            line3.Linetype = Linetype.DashDot;
            line3.Lineweight = Lineweight.W25;
            line3.Layer = center;
            dxf.AddEntity(line3);

            Line line4 = new Line(p44, p45);
            line4.Linetype = Linetype.DashDot;
            line4.Lineweight = Lineweight.W25;
            line4.Layer = center;
            dxf.AddEntity(line4);

            Line line5 = new Line(p30, p46);
            line5.Linetype = Linetype.DashDot;
            line5.Lineweight = Lineweight.W25;
            line5.Layer = center;
            dxf.AddEntity(line5);




            Circle circlex = new Circle(new Vector3(p16.X, p16.Y, 0), dmin / 2);//圆
            circlex.Linetype = Linetype.DashDot;
            circlex.Lineweight = netDxf.Lineweight.W25;
            circlex.Layer = refin;
            dxf.AddEntity(circlex);

            Arc arc3 = fun.DrawArc(p22p, p16_, p23);
            fun.drawBArc(dxf, arc3, 0.5, contour);



            //标注样式
            //箭头样式
            DimensionStyle dimensionStyle = fun.CreateDimStyle();
            dimensionStyle.ArrowSize = 3.5;
            dimensionStyle.ExtLineExtend = 0.6;//标注延长线长度/2
            dimensionStyle.DimArrow1 = DimensionArrowhead.Closedfilled;
            dimensionStyle.DimArrow2 = DimensionArrowhead.Closedfilled;
            dimensionStyle.TextHeight = 3.5;
            double offset = 10;


            fun.dimrot1(dxf, p2, p15, 0, d1 / 2, 2, 1.2, 1.6, 0.9, "  d1=" + d1/scale , "", "");
            fun.dimrot1(dxf, p14, p6, -90, d1 / 2, 2, 1.2, 1.6, 0.9, "  l1=" + l1 / scale, "", "");

            fun.dimrot1(dxf, p10, p6, 180, d1 * 2, 2, 1.2, 1.6, 0.9, "  f=" + f / scale, "", "");
            fun.dimrot1(dxf, p7, p8, 90 + (90 - eper), d1, 2, 1.2, 1.6, 0.9, "  l2=" + l2 / scale, "", "");
            fun.dimrot1(dxf, p2, p15, 0, d1 / 2, 2, 1.2, 1.6, 0.9, "  d1=" + d1 / scale, "", "");
            fun.dimrot1(dxf, p17, p23, -90, dmin * 1.5, 2, 1.2, 1.6, 0.9, "  h1=" + h1 / scale, "", "");
            fun.dimrot1(dxf, p17, fun.Polar(p17, pi, dmin), 180, d1 * 2, 2, 1.2, 1.6, 0.9, "  dmin=" + dmin / scale, "", "");
            fun.dimrot1(dxf, p17, p19, -90 + γf, dmin / 4, 2, 1.2, 1.6, 0.9, "  sb=" + sb / scale, "", "");
            fun.jdbz2(dxf, new Line(p6, fun.Polar(p6, -(eper_ + pj_), 0.1)), new Line(p6, fun.Polar(p6, -pj_, 0.1)), d1 * 2, 1.2, 1.2, 0.9, "eper=" + eper + "°" + "±1°", "", "");
            fun.jdbz2(dxf, new Line(p6, p4), new Line(p6, fun.Polar(p6, pi / -2, 0.1)), 4 * f, 1.2, 1.2, 0.9, "pj=" + pj + "°", "", "");

            Line line10 = new Line(p103, p104);
            line10.Linetype = Linetype.DashDot;
            line10.Lineweight = Lineweight.W25;
            line10.Layer = dimensioning;
            dxf.AddEntity(line10);

            Line line11 = new Line(p105, p106);
            line11.Linetype = Linetype.DashDot;
            line11.Lineweight = Lineweight.W25;
            line11.Layer = dimensioning;
            dxf.AddEntity(line11);

            Line line12 = new Line(p122, p123);
            line12.Lineweight = Lineweight.W25;
            line12.Layer = dimensioning;
            dxf.AddEntity(line12);

            Line line13 = new Line(p110, p111);
            line13.Lineweight = Lineweight.W25;
            line13.Layer = dimensioning;
            dxf.AddEntity(line13);

            Line line14 = new Line(p117, p118);
            line14.Lineweight = Lineweight.W25;
            line14.Layer = dimensioning;
            dxf.AddEntity(line14);

            Line line15 = new Line(p124, p128);
            line15.Lineweight = Lineweight.W25;
            line15.Layer = dimensioning;
            dxf.AddEntity(line15);

            Solid entity5 = new Solid(p107, p108, p109);
            dxf.AddEntity(entity5);
            Solid entity6 = new Solid(p114, p115, p116);
            dxf.AddEntity(entity6);
            Solid entity7 = new Solid(p119, p120, p121);
            dxf.AddEntity(entity7);
            Solid entity8 = new Solid(p6, p125, p126);
            dxf.AddEntity(entity8);

            Text txt2 = new Text("A", fun.Polar(p104, -eper_, 1.6), 1.6, -5);
            dxf.AddEntity(txt2);
            Text txt3 = new Text("A", fun.Polar(p117, pi / 2, 2), 1.6, -5);
            dxf.AddEntity(txt3);
          //  Text txt4 = new Text("X", fun.Polar(p123, -pi / 2, 1.6), 1.6, 0);
           // dxf.AddEntity(txt4);
            Text txt5 = new Text("γε", p128, 1.6, 45);
            dxf.AddEntity(txt5);
            Text txt6 = new Text("an=" + an + "°", fun.Polar(p35, pi, 8), 1.6, 0);
            dxf.AddEntity(txt6);
           // Text txt7 = new Text("X", fun.Polar(p16, pi / 2, dmin / 2), 1.6, 0);
           // dxf.AddEntity(txt7);
            Text txt8 = new Text("A-A", fun.Polar(p33, pi / 2, 3), 1.6, 0);
            dxf.AddEntity(txt8);

            if (an == 7)
            {
                Line line6 = new Line(p30, fun.Polar(p30, pi / -2, l2 + 5));
                line6.Lineweight = Lineweight.W25;
                line6.Layer = refin;
                dxf.AddEntity(line6);

                LwPolyline poly9 = new LwPolyline();
                poly9.Vertexes.Add(new LwPolylineVertex(p53));
                poly9.Vertexes[0].Bulge = Math.Tan((10 * pi / 180) / 4);
                poly9.Vertexes.Add(new LwPolylineVertex(fun.Polar(p47, pi, 1.6)));
                poly9.Vertexes.Add(new LwPolylineVertex(fun.Polar(p47, 0, 1.6)));
                poly9.Vertexes[2].Bulge = Math.Tan((10 * pi / 180) / 4);
                poly9.Vertexes.Add(new LwPolylineVertex(p52));
                poly9.Lineweight = Lineweight.W25;
                poly9.Layer = dimensioning;

                dxf.AddEntity(poly9);

                Solid entity1 = new Solid(p47, p48, p49);
                dxf.AddEntity(entity1);
                Solid entity2 = new Solid(p47, p50, p51);
                dxf.AddEntity(entity2);
                Text txt = new Text("0°" + "±1°", fun.Polar(p53, pi / 2, 0.1), 1.6, 0.9);
                dxf.AddEntity(txt);




                Line line9 = new Line(p17, p55);
                line9.Lineweight = Lineweight.W25;
                line9.Layer = refin;
                dxf.AddEntity(line9);

                LwPolyline poly8 = new LwPolyline();
                poly8.Vertexes.Add(new LwPolylineVertex(p100));
                poly8.Vertexes[0].Bulge = -Math.Tan((10 * pi / 180) / 4);
                poly8.Vertexes.Add(new LwPolylineVertex(fun.Polar(p56, pi / 2, 1.6)));
                poly8.Vertexes.Add(new LwPolylineVertex(fun.Polar(p56, pi / -2, 1.6)));
                poly8.Vertexes[2].Bulge = -Math.Tan((10 * pi / 180) / 4);
                poly8.Vertexes.Add(new LwPolylineVertex(p101));
                poly8.Lineweight = Lineweight.W25;
                poly8.Layer = dimensioning;

                dxf.AddEntity(poly8);






                Solid entity3 = new Solid(p56, p57, p58);
                dxf.AddEntity(entity3);
                Solid entity4 = new Solid(p56, p59, p60);
                dxf.AddEntity(entity4);
                Text txt1 = new Text("γf=" + "γf°" + "±1°", p100, 1.6, 90);
                dxf.AddEntity(txt1);













            }

            else
            {
                fun.jdbz2(dxf, new Line(p30, fun.Polar(p30, pi / -2, 0.1)), new Line(p30, fun.Polar(p30, pi / -2 + γf * pi / 180, 0.1)), d1 / 2, 1.6, 0.5, 0.9, "γf=" + γf + "°" + "±1°", "", "");
                fun.jdbz2(dxf, new Line(p17, fun.Polar(p17, 0, 0.1)), new Line(p17, fun.Polar(p17, γf * pi / 180, 0.1)), d1 / 2, 1.6, 0.5, 0.9, "γf=" + γf + "°", "", "");

            }


            double isframe = Convert.ToInt32(data["isframe"]);
            String isframe_chose = Convert.ToString(data["isframe_chose"]);
            if (isframe == 1)
            {
                if (isframe_chose.Equals("0"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA0X(dxf, new Vector2(p0.X - 1189 / 2.0, p0.Y + 841 / 2.0), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }

                if (isframe_chose.Equals("1"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA1X(dxf, new Vector2(p0.X - 841 / 2.0, p0.Y + 594 / 2.0), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }

                if (isframe_chose.Equals("2"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA2X(dxf, new Vector2(p0.X - 594 / 2.0, p0.Y + 420 / 2.0), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }

                if (isframe_chose.Equals("3"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA3X(dxf, new Vector2(p0.X - 420 / 2.0, p0.Y + 297 / 2.0), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }

                if (isframe_chose.Equals("4X"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA4X(dxf, new Vector2(p0.X - 297 / 2.0, p0.Y + 210 / 2.0 - 10 * 2.26), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }

                if (isframe_chose.Equals("4Y"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA4Y(dxf, new Vector2(p0.X - 210 / 2.0, p0.Y + 297 / 2.0), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }
            }

            fun.SetLayer(dxf);
            fun.SetByLayer(dxf);


            dxf.DrawingVariables.AcadVer = DxfVersion.AutoCad2007;
            dxf.Save(path);
        }

        public static void Centringbit(Dictionary<string, Object> data)    //定心钻
        {
            DxfDocument dxf = new DxfDocument();
            dxf.Layers["0"].Lineweight = Lineweight.W25;
            Layer contour = new Layer("contour");//轮廓层
            Layer dimensioning = new Layer("dimensioning");//尺寸层
            Layer refin = new Layer("refin");//基准线/内轮廓/虚线
            Layer center = new Layer("center");//中心线
            Layer textlayer = new Layer("textlayer");//文本层
            Layer hatching = new Layer("hatching");//填充层
            Layer additionalline = new Layer("additionalline");//附加线
            Layer cutting = new Layer("cutting");//切削层
            fun.SetLayer(dxf);

            /*
            string path = Convert.ToString(data["path"]);
            double pi = Math.PI;
            double d = 4;
            double l = 12;
            double L = 52;
            double dj = 0.5;
            double eper=120;
            */
            double scale = Convert.ToDouble(data["scale"]); //放大系数
            string path = Convert.ToString(data["path"]);
            double pi = Math.PI;
            double d = Convert.ToDouble(data["dc"]) * scale;
            double l = Convert.ToDouble(data["lcf"]) * scale;
            double L = Convert.ToDouble(data["oal"]) * scale;
            double dj = Convert.ToDouble(data["dj"]);
            double eper = Convert.ToDouble(data["eper"]);
            double isframe = Convert.ToInt32(data["isframe"]);
            String isframe_chose = Convert.ToString(data["isframe_chose"]);
            

            /**double d = 4;
            double L = 52;
            double l = 12;
            double dj = 0.5;
            double eper = 120;*/


            Vector2 zx1 = new Vector2(-5, 0);
            Vector2 zx2 = fun.Polar(zx1, 0, L + 10);

            Vector2 p0 = new Vector2(0, 0);
            Vector2 p1 = fun.Polar(p0, eper / 2 * pi / 180, d / 2 / Math.Sin(pi / 3));
            Vector2 p2 = fun.mirrorpoint(p1, zx1, zx2);
            Vector2 p3 = fun.Polar(p0, 0, p1.X * 2.0);
            Vector2 p4 = new Vector2(p0.X + l / 2.474, p0.Y + d / 3.1496);
            Vector2 p5 = new Vector2(p0.X + l / 2.32558, p0.Y - d / 3.0769);
            Vector2 p6 = new Vector2(p0.X + l / 1.091, p0.Y + d / 2.06185);
            Vector2 p7 = new Vector2(p0.X + l / 1.03448, p0.Y + d / 14.81481);
            Vector2 p8 = new Vector2(p0.X + l / 1.22825, p0.Y - d / 1.923);
            Vector2 p9 = new Vector2(p0.X + L - 0.8, p6.Y);
            Vector2 p10 = new Vector2(p9.X + 0.8, p9.Y - 0.8);
            Vector2 p11 = fun.mirrorpoint(p10, zx1, zx2);
            Vector2 p12 = fun.mirrorpoint(p9, zx1, zx2);




            LwPolyline poly1 = new LwPolyline();
            poly1.Vertexes.Add(new LwPolylineVertex(p4));
            poly1.Vertexes[0].Bulge = Math.Tan((0.90390381) / 4);
            poly1.Vertexes.Add(new LwPolylineVertex(p7));
            poly1.Vertexes[1].Bulge = Math.Tan(104 * pi / 180 / 4);
            poly1.Vertexes.Add(new LwPolylineVertex(p6));
            poly1.Vertexes[2].Bulge = Math.Tan(23 * pi / 180 / 4);
            poly1.Vertexes.Add(new LwPolylineVertex(p4));
            poly1.Vertexes[3].Bulge = Math.Tan((0.42436206) / 4);
            poly1.Vertexes.Add(new LwPolylineVertex(p1));
            poly1.Vertexes.Add(new LwPolylineVertex(p0));
            poly1.Vertexes.Add(new LwPolylineVertex(p3));
            poly1.Vertexes.Add(new LwPolylineVertex(p1));
            poly1.Vertexes.Add(new LwPolylineVertex(p3));
            poly1.Vertexes[8].Bulge = -Math.Tan((0.48411305) / 4);
            poly1.Vertexes.Add(new LwPolylineVertex(p5));
            poly1.Vertexes[9].Bulge = -Math.Tan((0.59502547) / 4);
            poly1.Vertexes.Add(new LwPolylineVertex(p2));
            poly1.Vertexes.Add(new LwPolylineVertex(p0));
            poly1.Vertexes.Add(new LwPolylineVertex(p3));
            poly1.Vertexes[12].Bulge = -Math.Tan((0.48411305) / 4);
            poly1.Vertexes.Add(new LwPolylineVertex(p5));
            poly1.Vertexes[13].Bulge = Math.Tan((0.30663098) / 4);
            poly1.Vertexes.Add(new LwPolylineVertex(p8));

            poly1.Vertexes.Add(new LwPolylineVertex(p12));
            poly1.Vertexes.Add(new LwPolylineVertex(p11));
            poly1.Vertexes.Add(new LwPolylineVertex(p10));
            poly1.Vertexes.Add(new LwPolylineVertex(p9));
            poly1.Vertexes.Add(new LwPolylineVertex(p12));
            poly1.Vertexes.Add(new LwPolylineVertex(p9));
            poly1.Vertexes.Add(new LwPolylineVertex(p6));
            // poly1.Vertexes.Add(new LwPolylineVertex(p));
            fun.PolyFill(dxf, poly1, 0.25, contour);
            //dxf.AddEntity(poly1);

            Line line1 = new Line(zx1, zx2);
            line1.Lineweight = Lineweight.W25;//Lineweight指线宽
            line1.Layer = center;//Layer指图层
            line1.Linetype = Linetype.ByLayer;//Linetype指是点划线还是虚线什么的
            dxf.AddEntity(line1);



            fun.dimrot1(dxf, p1, p2, 90, d/2+10, 2, 1.2, 1.6, 0.9, "  d=" + d/scale, "", "");
            fun.dimrot1(dxf, p0, p10, 0, d/2+20, 2, 1.2, 1.6, 0.9, "  L=" + L/scale, "", "");
            fun.dimrot1(dxf, p0, fun.Polar(p7, 1.08752241, l * (0.86539032 / 12.0)), 0, d, 2, 1.2, 1.6, 0.9, "  l=" + l/ scale, "", "");


            
            if (isframe == 1)
            {
                if (isframe_chose.Equals("0"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA0X(dxf, new Vector2(p0.X - 1189 / 2.0, p0.Y + 841 / 2.0), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }

                if (isframe_chose.Equals("1"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA1X(dxf, new Vector2(p0.X - 841 / 2.0, p0.Y + 594 / 2.0), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }

                if (isframe_chose.Equals("2"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA2X(dxf, new Vector2(p0.X - 594 / 2.0, p0.Y + 420 / 2.0), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }

                if (isframe_chose.Equals("3"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA3X(dxf, new Vector2(p0.X - 420 / 2.0, p0.Y + 297 / 2.0), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }

                if (isframe_chose.Equals("4X"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA4X(dxf, new Vector2(p0.X - 297 / 2.0, p0.Y + 210 / 2.0 - 10 * 2.26), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }

                if (isframe_chose.Equals("4Y"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA4Y(dxf, new Vector2(p0.X - 210 / 2.0, p0.Y + 297 / 2.0), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }
            }




            fun.SetLayer(dxf);
            fun.SetByLayer(dxf);

            dxf.DrawingVariables.AcadVer = DxfVersion.AutoCad2007;
            dxf.Save(path);
        }

        public static void Centerdrill(Dictionary<string, Object> data)    //中心钻
        {
            DxfDocument dxf = new DxfDocument();
            dxf.Layers["0"].Lineweight = Lineweight.W25;
            Layer contour = new Layer("contour");//轮廓层
            Layer dimensioning = new Layer("dimensioning");//尺寸层
            Layer refin = new Layer("refin");//基准线/内轮廓/虚线
            Layer center = new Layer("center");//中心线
            Layer textlayer = new Layer("textlayer");//文本层
            Layer hatching = new Layer("hatching");//填充层
            Layer additionalline = new Layer("additionalline");//附加线
            Layer cutting = new Layer("cutting");//切削层
            fun.SetLayer(dxf);



            /*
            string path = Convert.ToString(data["path"]);
            double pi = Math.PI;
            double d = 10.0;
            double d1 = 25.0;
            double d2 = 0;
            double l = 100.0;
            double l1 = 26.5;
            double R = 31.5;
            double eper = 120;
            double eper_ = eper / 2 * pi / 180;
            */
            /*
            string path = Convert.ToString(data["path"]);
            double pi = Math.PI;
            double d = 5.0;
            double d1 = 12.5;
            double d2 = 0;
            double l = 63.0;
            double l1 =6.3;
            double R = 0;
            double eper = 120;
            double eper_ = eper / 2 * pi / 180;
            */
            /*
            string path = Convert.ToString(data["path"]);
            double pi = Math.PI;
            double d = 5.0;
            double d1 = 18.0;
            double d2 = 10.6;
            double l = 75;
            double l1 = 6.3;
            double R = 0;
            double eper = 120;
            double eper_ = eper / 2 * pi / 180;
            */
            double scale = Convert.ToDouble(data["scale"]);
            string path = Convert.ToString(data["path"]);
            double pi = Math.PI;
            double d = Convert.ToDouble(data["dc1"]) * scale;
            double d1 = Convert.ToDouble(data["dmm"]) * scale;
            double d2 = Convert.ToDouble(data["dc2"]);
            double l = Convert.ToDouble(data["oal"]) * scale;
            double l1 = Convert.ToDouble(data["sdl1"]) * scale;
            double R = Convert.ToDouble(data["r"]);
            double eper = Convert.ToDouble(data["eper"]);
            double eper_ = eper / 2 * pi / 180;

            Vector2 zx1 = new Vector2(-5, 0);
            Vector2 zx2 = fun.Polar(zx1, 0, l + 10);
            Vector2 p1 = new Vector2(0, 0);
            Vector2 zxd = fun.Polar(p1, 0, l / 2);
            Vector2 p2 = fun.Polar(p1, eper_, (d / 2) / Math.Sin(eper_));
            Vector2 p3 = fun.mirrorpoint(p2, zx1, zx2);

            Vector2 p4;
            if (d2 == 0 || R == 0 && d2 != 0)
            {
                p4 = fun.Polar(p1, 0, l1 * (0.25886838 / 0.8));

            }
            else
            {
                p4 = fun.Polar(p1, 0, l1 * (0.97075643 / 3));

            }


            Vector2 p5 = fun.Polar(fun.Polar(p1, pi / 2, d / 2), 0, l1);
            Vector2 p6 = fun.mirrorpoint(p5, zx1, zx2);
            Vector2 p7 = fun.Polar(p1, 0, p4.X + l1 * (0.60347674 / 0.8));
            /*
            Vector2 p5_1 = fun.Polar(p5, 0, Math.Sqrt((((d1 - d) / 2) * ((d1 - d) / 2)) + ((l * (3.25757537 / 31.5)) * (l * (3.25757537 / 31.5)))));
            Vector2 p5_2 = fun.Polar(p5, pi / 2, Math.Sqrt((((d1 - d) / 2) * ((d1 - d) / 2)) + ((l * (3.25757537 / 31.5)) * (l * (3.25757537 / 31.5)))));
            System.Diagnostics.Debug.WriteLine( Math.Sqrt((((d1 - d) / 2) * ((d1 - d) / 2)) + ((l * (3.25757537 / 31.5)) * (l * (3.25757537 / 31.5)))));
            Arc arc1 = fun.DrawArc (p5_1,p5,p5_2);            
            Vector2 p8_ = fun.Polar(p1, pi / 2, d1 / 2);
            Vector2 p8 = fun.getPointForArcandLine(p8_ , fun.Polar (p8_ ,0,l), p5, arc1);
            */
            Vector2 p8;
            Vector2 p25;
            Vector2 p26;
            Vector2 p27;
            Vector2 p28;

            p25 = fun.Polar(p5, pi / 6, d2 - d);
            p26 = fun.mirrorpoint(p25, zx1, zx2);
            p27 = fun.PointRotate(zxd, p25, pi);
            p28 = fun.PointRotate(zxd, p26, pi);

            if (d2 == 0 && R == 0)
            {

                p8 = fun.Polar(p5, pi / 6, (d1 - d));

            }
            else
            {

                p8 = fun.Polar(p25, pi / 3, ((d1 - d2) / 2) / Math.Cos(pi / 6));

            }

            Vector2 p9 = fun.mirrorpoint(p8, zx1, zx2);
            Vector2 p9_ = fun.Polar(p9, 1.81100631, 50);
            Vector2 p10 = fun.Inters(p9, p9_, zx1, zx2);
            Vector2 p11;
            Vector2 p12;
            Vector2 p29 = fun.Polar(p9, 1.61631736, d1 * (1.90327879 / 4));
            Vector2 p30 = fun.PointRotate(zxd, p29, pi);

            if (d2 == 0 && R == 0)
            {
                p11 = fun.Polar(p9, 0.99604451, d1 * (19.68980293 / 48.6650066));
                p12 = fun.Polar(p9, 0, d1 * (20.56521519 / 48.6650066));
            }
            else
            {
                p11 = fun.Polar(p9, 1.17825328, d1 * (1.68721823 / 4));
                p12 = fun.Polar(p9, 0, d1 * (2.21864798 / 4));
            }



            Vector2 p13 = fun.Polar(p1, 0, l);
            Vector2 p14 = fun.PointRotate(zxd, p2, pi);
            Vector2 p15 = fun.PointRotate(zxd, p3, pi);
            Vector2 p16 = fun.PointRotate(zxd, p4, pi);
            Vector2 p17 = fun.PointRotate(zxd, p5, pi);
            Vector2 p18 = fun.PointRotate(zxd, p6, pi);
            Vector2 p19 = fun.PointRotate(zxd, p7, pi);
            Vector2 p20 = fun.PointRotate(zxd, p8, pi);
            Vector2 p21 = fun.PointRotate(zxd, p9, pi);
            Vector2 p22 = fun.PointRotate(zxd, p10, pi);
            Vector2 p23 = fun.PointRotate(zxd, p11, pi);
            Vector2 p24 = fun.PointRotate(zxd, p12, pi);
            Vector2 p33;
            Vector2 p34;
            Vector2 p35;
            Vector2 p36;
            if (R != 0)
            {
                double ang1 = fun.CalAngle(p2, p8);
                double p31j = fun.CalDistance(p2, p8);
                Vector2 p31 = fun.Polar(p2, ang1, p31j / 2);
                Vector2 p32 = fun.Polar(p31, ang1 + pi / 2, 100);
                Arc arc5 = fun.DrawArc(fun.Polar(p2, 0, R), p2, fun.Polar(p2, pi / 2, R));
                p33 = fun.getPointForArcandLine(p31, p32, p2, arc5);

            }
            else
            {

                p33 = fun.Polar(p1, 0, 10);
            }
            p34 = fun.mirrorpoint(p33, zx1, zx2);
            p35 = fun.mirrorpoint(p33, fun.Polar(p1, 0, fun.CalDistance(p1, p13) / 2), fun.Polar(fun.Polar(p1, 0, fun.CalDistance(p1, p13) / 2), 90 * pi / 180, 10));
            p36 = fun.mirrorpoint(p34, fun.Polar(p1, 0, fun.CalDistance(p1, p13) / 2), fun.Polar(fun.Polar(p1, 0, fun.CalDistance(p1, p13) / 2), 90 * pi / 180, 10));


            Arc arc10 = fun.DrawArc(p2, p33, p8);

            Vector2 p37 = fun.Polar(p2, pi / 2, d * 1.0 / 5.0);
            Vector2 p38 = fun.getPointForArcandLine(p37, fun.Polar(p37, 0, 50), p33, arc10);
            Vector2 p39 = fun.Polar(p38, pi * 3 / 4.0 + 10 * pi / 180, 0.5 / Math.Cos(10 * pi / 180));
            Vector2 p40 = fun.Polar(p38, pi * 3 / 4.0 - 10 * pi / 180, 0.5 / Math.Cos(10 * pi / 180));
            Vector2 p41 = fun.Polar(p38, pi * 3 / 4.0, 0.5);
            Vector2 p42 = fun.Polar(p41, pi * 3 / 4.0, d1);
            Vector2 p43 = fun.Polar(p42, 0, d1 / 2);
            Vector2 p44 = fun.Polar(p42, 0, d1 / 4);
            if (d2 == 0 && R == 0)
            {
                LwPolyline poly1 = new LwPolyline();
                poly1.Vertexes.Add(new LwPolylineVertex(p11));
                poly1.Vertexes[0].Bulge = Math.Tan((0.64317749) / 4);
                poly1.Vertexes.Add(new LwPolylineVertex(p8));
                poly1.Vertexes.Add(new LwPolylineVertex(p5));
                poly1.Vertexes[2].Bulge = -Math.Tan((0.97700169) / 4);
                poly1.Vertexes.Add(new LwPolylineVertex(p7));
                poly1.Vertexes.Add(new LwPolylineVertex(p10));
                poly1.Vertexes.Add(new LwPolylineVertex(p1));
                poly1.Vertexes.Add(new LwPolylineVertex(p2));
                poly1.Vertexes.Add(new LwPolylineVertex(p5));
                poly1.Vertexes.Add(new LwPolylineVertex(p2));
                poly1.Vertexes[8].Bulge = -Math.Tan((0.86494247) / 4);
                poly1.Vertexes.Add(new LwPolylineVertex(p4));
                poly1.Vertexes.Add(new LwPolylineVertex(p1));
                poly1.Vertexes.Add(new LwPolylineVertex(p3));
                poly1.Vertexes.Add(new LwPolylineVertex(p6));
                poly1.Vertexes.Add(new LwPolylineVertex(p9));
                poly1.Vertexes.Add(new LwPolylineVertex(p12));

                //  dxf.AddEntity(poly1);
                fun.PolyFill(dxf, poly1, 0.1, contour);
                Arc arc2 = fun.DrawArc3(p12, p11, p10);
                //dxf.AddEntity(arc2);
                fun.drawBArc(dxf, arc2, 0.1, contour); ;



                LwPolyline poly2 = new LwPolyline();
                poly2.Vertexes.Add(new LwPolylineVertex(p23));
                poly2.Vertexes[0].Bulge = Math.Tan((0.64317749) / 4);
                poly2.Vertexes.Add(new LwPolylineVertex(p20));
                poly2.Vertexes.Add(new LwPolylineVertex(p17));
                poly2.Vertexes[2].Bulge = -Math.Tan((0.97700169) / 4);
                poly2.Vertexes.Add(new LwPolylineVertex(p19));
                poly2.Vertexes.Add(new LwPolylineVertex(p22));
                poly2.Vertexes.Add(new LwPolylineVertex(p13));
                poly2.Vertexes.Add(new LwPolylineVertex(p14));
                poly2.Vertexes.Add(new LwPolylineVertex(p17));
                poly2.Vertexes.Add(new LwPolylineVertex(p14));
                poly2.Vertexes[8].Bulge = -Math.Tan((0.86494247) / 4);
                poly2.Vertexes.Add(new LwPolylineVertex(p16));
                poly2.Vertexes.Add(new LwPolylineVertex(p13));
                poly2.Vertexes.Add(new LwPolylineVertex(p15));
                poly2.Vertexes.Add(new LwPolylineVertex(p18));
                poly2.Vertexes.Add(new LwPolylineVertex(p21));
                poly2.Vertexes.Add(new LwPolylineVertex(p24));
                //dxf.AddEntity(poly2);
                fun.PolyFill(dxf, poly2, 0.1, contour);
                Arc arc3 = fun.DrawArc3(p24, p23, p22);
                // dxf.AddEntity(arc3);
                fun.drawBArc(dxf, arc3, 0.1, contour); ;

                LwPolyline poly3 = new LwPolyline();
                poly3.Vertexes.Add(new LwPolylineVertex(p5));
                poly3.Vertexes.Add(new LwPolylineVertex(p2));
                poly3.Vertexes.Add(new LwPolylineVertex(p1));
                poly3.Vertexes.Add(new LwPolylineVertex(p3));
                poly3.Vertexes.Add(new LwPolylineVertex(p6));
                poly3.Vertexes.Add(new LwPolylineVertex(p9));
                poly3.Vertexes.Add(new LwPolylineVertex(p20));
                poly3.Vertexes.Add(new LwPolylineVertex(p17));
                poly3.Vertexes.Add(new LwPolylineVertex(p14));
                poly3.Vertexes.Add(new LwPolylineVertex(p13));
                poly3.Vertexes.Add(new LwPolylineVertex(p15));
                poly3.Vertexes.Add(new LwPolylineVertex(p18));
                poly3.Vertexes.Add(new LwPolylineVertex(p21));
                poly3.Vertexes.Add(new LwPolylineVertex(p8));
                poly3.Vertexes.Add(new LwPolylineVertex(p5));
                dxf.AddEntity(poly3);
                fun.PolyFill(dxf, poly3, 0.1, contour);
            }
            else if (d2 != 0)
            {
                LwPolyline poly1 = new LwPolyline();
                poly1.Vertexes.Add(new LwPolylineVertex(p11));
                poly1.Vertexes[0].Bulge = Math.Tan((0.63924589) / 4);
                poly1.Vertexes.Add(new LwPolylineVertex(p8));
                poly1.Vertexes.Add(new LwPolylineVertex(p25));
                poly1.Vertexes[2].Bulge = -Math.Tan((0.44632916) / 4);
                poly1.Vertexes.Add(new LwPolylineVertex(p29));
                poly1.Vertexes[3].Bulge = Math.Tan((0.44632916) / 4);
                poly1.Vertexes.Add(new LwPolylineVertex(p25));
                poly1.Vertexes.Add(new LwPolylineVertex(p5));
                poly1.Vertexes.Add(new LwPolylineVertex(p7));
                poly1.Vertexes.Add(new LwPolylineVertex(p10));
                poly1.Vertexes.Add(new LwPolylineVertex(p1));
                poly1.Vertexes.Add(new LwPolylineVertex(p2));
                poly1.Vertexes.Add(new LwPolylineVertex(p5));
                poly1.Vertexes.Add(new LwPolylineVertex(p2));
                poly1.Vertexes.Add(new LwPolylineVertex(p4));
                poly1.Vertexes.Add(new LwPolylineVertex(p1));
                poly1.Vertexes.Add(new LwPolylineVertex(p3));
                poly1.Vertexes.Add(new LwPolylineVertex(p6));
                poly1.Vertexes.Add(new LwPolylineVertex(p26));
                poly1.Vertexes.Add(new LwPolylineVertex(p9));
                poly1.Vertexes.Add(new LwPolylineVertex(p12));

                // dxf.AddEntity(poly1);
                fun.PolyFill(dxf, poly1, 0.1, contour);
                Arc arc2 = fun.DrawArc3(p12, p11, p10);
                // dxf.AddEntity(arc2);
                fun.drawBArc(dxf, arc2, 0.1, contour); ;

                LwPolyline poly2 = new LwPolyline();
                poly2.Vertexes.Add(new LwPolylineVertex(p23));
                poly2.Vertexes[0].Bulge = Math.Tan((0.63924589) / 4);
                poly2.Vertexes.Add(new LwPolylineVertex(p20));
                poly2.Vertexes.Add(new LwPolylineVertex(p27));
                poly2.Vertexes[2].Bulge = -Math.Tan((0.44632916) / 4);
                poly2.Vertexes.Add(new LwPolylineVertex(p30));
                poly2.Vertexes[3].Bulge = Math.Tan((0.44632916) / 4);
                poly2.Vertexes.Add(new LwPolylineVertex(p27));
                poly2.Vertexes.Add(new LwPolylineVertex(p17));

                poly2.Vertexes.Add(new LwPolylineVertex(p19));
                poly2.Vertexes.Add(new LwPolylineVertex(p22));

                poly2.Vertexes.Add(new LwPolylineVertex(p13));
                poly2.Vertexes.Add(new LwPolylineVertex(p14));
                poly2.Vertexes.Add(new LwPolylineVertex(p17));
                poly2.Vertexes.Add(new LwPolylineVertex(p14));

                poly2.Vertexes.Add(new LwPolylineVertex(p16));
                poly2.Vertexes.Add(new LwPolylineVertex(p13));
                poly2.Vertexes.Add(new LwPolylineVertex(p15));
                poly2.Vertexes.Add(new LwPolylineVertex(p18));
                poly2.Vertexes.Add(new LwPolylineVertex(p28));
                poly2.Vertexes.Add(new LwPolylineVertex(p21));
                poly2.Vertexes.Add(new LwPolylineVertex(p24));
                //dxf.AddEntity(poly2);
                fun.PolyFill(dxf, poly2, 0.1, contour);
                Arc arc3 = fun.DrawArc3(p24, p23, p22);
                // dxf.AddEntity(arc3);
                fun.drawBArc(dxf, arc3, 0.1, contour);

                LwPolyline poly3 = new LwPolyline();
                poly3.Vertexes.Add(new LwPolylineVertex(p5));
                poly3.Vertexes.Add(new LwPolylineVertex(p2));
                poly3.Vertexes.Add(new LwPolylineVertex(p1));
                poly3.Vertexes.Add(new LwPolylineVertex(p3));
                poly3.Vertexes.Add(new LwPolylineVertex(p6));
                poly3.Vertexes.Add(new LwPolylineVertex(p26));
                poly3.Vertexes.Add(new LwPolylineVertex(p9));
                poly3.Vertexes.Add(new LwPolylineVertex(p20));
                poly3.Vertexes.Add(new LwPolylineVertex(p27));
                poly3.Vertexes.Add(new LwPolylineVertex(p17));
                poly3.Vertexes.Add(new LwPolylineVertex(p14));
                poly3.Vertexes.Add(new LwPolylineVertex(p13));
                poly3.Vertexes.Add(new LwPolylineVertex(p15));
                poly3.Vertexes.Add(new LwPolylineVertex(p18));
                poly3.Vertexes.Add(new LwPolylineVertex(p28));
                poly3.Vertexes.Add(new LwPolylineVertex(p21));
                poly3.Vertexes.Add(new LwPolylineVertex(p8));
                poly3.Vertexes.Add(new LwPolylineVertex(p25));
                poly3.Vertexes.Add(new LwPolylineVertex(p5));
                dxf.AddEntity(poly3);
                fun.PolyFill(dxf, poly3, 0.1, contour);
            }
            else
            {
                LwPolyline poly1 = new LwPolyline();
                poly1.Vertexes.Add(new LwPolylineVertex(p11));
                poly1.Vertexes[0].Bulge = Math.Tan((0.63924589) / 4);
                poly1.Vertexes.Add(new LwPolylineVertex(p8));

                // dxf.AddEntity(poly1);
                fun.PolyFill(dxf, poly1, 0.1, contour);


                LwPolyline poly11 = new LwPolyline();
                poly11.Vertexes.Add(new LwPolylineVertex(p10));
                poly11.Vertexes.Add(new LwPolylineVertex(p1));
                poly11.Vertexes.Add(new LwPolylineVertex(p4));
                poly11.Vertexes.Add(new LwPolylineVertex(p2));
                poly11.Vertexes.Add(new LwPolylineVertex(p1));
                poly11.Vertexes.Add(new LwPolylineVertex(p3));
                //dxf.AddEntity(poly11);
                fun.PolyFill(dxf, poly11, 0.1, contour);









                Arc arc2 = fun.DrawArc3(p12, p11, p10);
                // dxf.AddEntity(arc2);
                fun.drawBArc(dxf, arc2, 0.1, contour);

                Arc arc6 = fun.DrawArc(p2, p33, p8);
                // dxf.AddEntity(arc6);

                fun.drawBArc(dxf, arc6, 0.1, contour); ;
                Arc arc7 = fun.DrawArc(p9, p34, p3);
                //dxf.AddEntity(arc7);
                fun.drawBArc(dxf, arc7, 0.1, contour); ;
                Arc arc8 = fun.DrawArc(p14, p36, p20);
                // dxf.AddEntity(arc8);
                fun.drawBArc(dxf, arc8, 0.1, contour); ;
                Arc arc9 = fun.DrawArc(p21, p35, p15);
                // dxf.AddEntity(arc9);
                fun.drawBArc(dxf, arc9, 0.1, contour); ;



                LwPolyline poly2 = new LwPolyline();
                poly2.Vertexes.Add(new LwPolylineVertex(p23));
                poly2.Vertexes[0].Bulge = Math.Tan((0.63924589) / 4);
                poly2.Vertexes.Add(new LwPolylineVertex(p20));
                //dxf.AddEntity(poly2);
                fun.PolyFill(dxf, poly2, 0.1, contour);

                LwPolyline poly22 = new LwPolyline();
                poly22.Vertexes.Add(new LwPolylineVertex(p22));
                poly22.Vertexes.Add(new LwPolylineVertex(p13));
                poly22.Vertexes.Add(new LwPolylineVertex(p16));
                poly22.Vertexes.Add(new LwPolylineVertex(p14));
                poly22.Vertexes.Add(new LwPolylineVertex(p13));
                poly22.Vertexes.Add(new LwPolylineVertex(p15));
                //dxf.AddEntity(poly22);
                fun.PolyFill(dxf, poly22, 0.1, contour);



                Arc arc3 = fun.DrawArc3(p24, p23, p22);
                // dxf.AddEntity(arc3);
                fun.drawBArc(dxf, arc3, 0.1, contour); ;



                Line line1 = new Line(p8, p21);
                Line line2 = new Line(p9, p20);
                fun.drawBline(dxf, line1, 0.1, contour);
                fun.drawBline(dxf, line2, 0.1, contour);


                Solid entity1 = new Solid(p38, p39, p40);
                dxf.AddEntity(entity1);
                Line line3 = new Line(p42, p41);
                Line line4 = new Line(p42, p43);
                dxf.AddEntity(line3);
                dxf.AddEntity(line4);
                Text txt = new Text("R", p44, 1.5, 0);
                dxf.AddEntity(txt);
            }
            Line line5 = new Line(zx1, zx2);
            line5.Lineweight = Lineweight.W25;//Lineweight指线宽
            line5.Layer = center;//Layer指图层
            line5.Linetype = Linetype.DashDot;//Linetype指是点划线还是虚线什么的
            dxf.AddEntity(line5);

            fun.dimrot1(dxf, p1, p13, 180, (d1-d)/2+20, 2, 1.2, 1.6, 0.9, "  l=" + l/scale, "", "");
            fun.dimrot1(dxf, p1, p6, 180, (d1-d) / 2 + 10, 2, 1.2, 1.6, 0.9, "  l1=" + l1/scale, "", "");
            fun.dimrot1(dxf, p2, p3, 90, 10, 2, 1.2, 1.6, 0.9, "  d=" + d/scale , "", "");
            fun.dimrot1(dxf, p8, p9, 90, 20, 2, 1.2, 1.6, 0.9, "  d1=" + d1/scale , "", "");
            //fun.jdbz2(dxf, new Line(p17, p20),new Line(p18,p21), d1 / 2, 1.6, 0.5, 0.9, "60°" , "", "");
            fun.jdbz2(dxf, new Line(p13, fun.Polar(p13, pi / -3, 0.1)), new Line(p13, fun.Polar(p13, pi / 3, 0.1)), d1 / 2, 1.6, 0.5, 0.9, "120°", "", "");


            /*
            fun.dimrot1(dxf, p0, fun.Polar(p7, 1.08752241, l * (0.86539032 / 12.0)), 0, d, 2, 1.2, 1.6, 0.9, "  l=" + l, "", "");
            fun.jdbz2(dxf, new Line(p17, fun.Polar(p17, 0, 0.1)), new Line(p17, fun.Polar(p17, γf * pi / 180, 0.1)), d1 / 2, 1.6, 0.5, 0.9, "γf=" + γf + "°", "", "");
            */

            double isframe = Convert.ToInt32(data["isframe"]);
            String isframe_chose = Convert.ToString(data["isframe_chose"]);
            Vector2 p0 = new Vector2(0, 0);
            if (isframe == 1)
            {
                if (isframe_chose.Equals("0"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA0X(dxf, new Vector2(p0.X - 1189 / 2.0, p0.Y + 841 / 2.0), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }

                if (isframe_chose.Equals("1"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA1X(dxf, new Vector2(p0.X - 841 / 2.0, p0.Y + 594 / 2.0), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }

                if (isframe_chose.Equals("2"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA2X(dxf, new Vector2(p0.X - 594 / 2.0, p0.Y + 420 / 2.0), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }

                if (isframe_chose.Equals("3"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA3X(dxf, new Vector2(p0.X - 420 / 2.0, p0.Y + 297 / 2.0), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }

                if (isframe_chose.Equals("4X"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA4X(dxf, new Vector2(p0.X - 297 / 2.0, p0.Y + 210 / 2.0 - 10 * 2.26), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }

                if (isframe_chose.Equals("4Y"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA4Y(dxf, new Vector2(p0.X - 210 / 2.0, p0.Y + 297 / 2.0), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }
            }



            fun.SetLayer(dxf);
            fun.SetByLayer(dxf);

            dxf.DrawingVariables.AcadVer = DxfVersion.AutoCad2007;
            dxf.Save(path);
        }

        public static void Centerdrill_(Dictionary<string, Object> data)    //整体A/B/R型中心钻
        {
            DxfDocument dxf = new DxfDocument();
            dxf.Layers["0"].Lineweight = Lineweight.W25;
            Layer contour = new Layer("contour");//轮廓层
            Layer dimensioning = new Layer("dimensioning");//尺寸层
            Layer refin = new Layer("refin");//基准线/内轮廓/虚线
            Layer center = new Layer("center");//中心线
            Layer textlayer = new Layer("textlayer");//文本层
            Layer hatching = new Layer("hatching");//填充层
            Layer additionalline = new Layer("additionalline");//附加线
            Layer cutting = new Layer("cutting");//切削层
            fun.SetLayer(dxf);

            double sl = 68;
            double scale = Convert.ToDouble(data["scale"]);

            if (sl <= 67)
            {
                scale = 2.2;
            }
            else if (67 < sl && sl <= 75)
            {
                scale = 1.8;
            }
            else if (75 < sl && sl <= 100)
            {
                scale = 1.4;
            }
            else
            {
                scale = 1;
            }

            //string path = Convert.ToString(data["path"]);
            //double pi = Math.PI;
            //double d = 10.0 * scale;
            //double d1 = 25.0 * scale;
            //double d2 = 0 * scale;
            //double l = 100.0 * scale;
            //double l1 = 6.5 * scale;
            //double R = 15 * scale;
            //double eper = 120;
            //double eper_ = eper / 2 * pi / 180;

            string path = Convert.ToString(data["path"]);
            double pi = Math.PI;
            double d = Convert.ToDouble(data["dc1"])*scale ;
            double d1 = Convert.ToDouble(data["dmm"]) * scale;
            double d2 = Convert.ToDouble(data["dc2"]) * scale;
            double l = Convert.ToDouble(data["oal"]) * scale;
            double l1 = Convert.ToDouble(data["sdl1"]) * scale;
            double R = Convert.ToDouble(data["r"]) * scale;
            double eper = Convert.ToDouble(data["eper"]) * scale;
            double eper_ = eper / 2 * pi / 180;

            /*
             string path = Convert.ToString(data["path"]);
             double pi = Math.PI;
             double d = 5.0;
             double d1 = 12.5;
             double d2 = 0;
             double l = 63.0;
             double l1 =6.3;
             double R = 0;
             double eper = 120;
             double eper_ = eper / 2 * pi / 180;
             */
            /*
            string path = Convert.ToString(data["path"]);
            double pi = Math.PI;
            double d = 5.0;
            double d1 = 18.0;
            double d2 = 10.6;
            double l = 75;
            double l1 = 6.3;
            double R = 0;
            double eper = 120;
            double eper_ = eper / 2 * pi / 180;
            */
            /*
            string path = Convert.ToString(data["path"]);
            double pi = Math.PI;
            double d = Convert.ToDouble(data["dc1"]); ;
            double d1 = Convert.ToDouble(data["dmm"]); ;
            double d2 = Convert.ToDouble(data["dc2"]); ;
            double l = Convert.ToDouble(data["oal"]); ;
            double l1 = Convert.ToDouble(data["sdl1"]); ;
            double R = Convert.ToDouble(data["r"]); ;
            double eper = Convert.ToDouble(data["eper"]); ;
            double eper_ = eper / 2 * pi / 180;
            */
            Vector2 zx1 = new Vector2(-5, 0);
            Vector2 zx2 = fun.Polar(zx1, 0, l + 10);
            Vector2 p1 = new Vector2(0, 0);
            Vector2 p1_ = fun.Polar(p1, 0, 50);
            Vector2 zxd = fun.Polar(p1, 0, l / 2);
            Vector2 p2 = fun.Polar(p1, eper_, (d / 2) / Math.Sin(eper_));
            Vector2 p2_ = fun.Polar(p2, pi / -2, 50);
            Vector2 p3 = fun.mirrorpoint(p2, zx1, zx2);
            Vector2 p4 = fun.Inters(p1, p1_, p2, p2_);




            Vector2 p5 = fun.Polar(fun.Polar(p1, pi / 2, d / 2), 0, l1);
            Vector2 p5_ = fun.Polar(p5, pi / -2, 50);
            Vector2 p6 = fun.mirrorpoint(p5, zx1, zx2);
            Vector2 p7 = fun.Inters(p1, p1_, p5, p5_);
            /*
            Vector2 p5_1 = fun.Polar(p5, 0, Math.Sqrt((((d1 - d) / 2) * ((d1 - d) / 2)) + ((l * (3.25757537 / 31.5)) * (l * (3.25757537 / 31.5)))));
            Vector2 p5_2 = fun.Polar(p5, pi / 2, Math.Sqrt((((d1 - d) / 2) * ((d1 - d) / 2)) + ((l * (3.25757537 / 31.5)) * (l * (3.25757537 / 31.5)))));
            System.Diagnostics.Debug.WriteLine( Math.Sqrt((((d1 - d) / 2) * ((d1 - d) / 2)) + ((l * (3.25757537 / 31.5)) * (l * (3.25757537 / 31.5)))));
            Arc arc1 = fun.DrawArc (p5_1,p5,p5_2);            
            Vector2 p8_ = fun.Polar(p1, pi / 2, d1 / 2);
            Vector2 p8 = fun.getPointForArcandLine(p8_ , fun.Polar (p8_ ,0,l), p5, arc1);
            */
            Vector2 p8;
            Vector2 p25;
            Vector2 p26;
            Vector2 p27;
            Vector2 p28;

            p25 = fun.Polar(p5, pi / 6, d2 - d);
            p26 = fun.mirrorpoint(p25, zx1, zx2);
            p27 = fun.PointRotate(zxd, p25, pi);
            p28 = fun.PointRotate(zxd, p26, pi);

            if (d2 == 0 && R == 0 || R != 0)
            {

                p8 = fun.Polar(p5, pi / 6, (d1 - d));

            }
            else
            {

                p8 = fun.Polar(p25, pi / 3, ((d1 - d2) / 2) / Math.Cos(pi / 6));

            }

            Vector2 p9 = fun.mirrorpoint(p8, zx1, zx2);
            Vector2 p9_ = fun.Polar(p9, 1.81100631, 50);
            Vector2 p10 = fun.Inters(p9, p9_, zx1, zx2);
            Vector2 p11;
            Vector2 p12;
            Vector2 p25_ = fun.Polar(p25, pi / -2, 50);
            Vector2 p29 = fun.Inters(p25, p25_, p1, p1_);
            Vector2 p30 = fun.PointRotate(zxd, p29, pi);


            p11 = fun.Polar(p9, 1.17825328, d1 * (1.68721823 / 4));
            p12 = fun.Polar(p9, 0, d1 * (2.21864798 / 4));




            Vector2 p13 = fun.Polar(p1, 0, l);
            Vector2 p14 = fun.PointRotate(zxd, p2, pi);
            Vector2 p15 = fun.PointRotate(zxd, p3, pi);
            Vector2 p16 = fun.PointRotate(zxd, p4, pi);
            Vector2 p17 = fun.PointRotate(zxd, p5, pi);
            Vector2 p18 = fun.PointRotate(zxd, p6, pi);
            Vector2 p19 = fun.PointRotate(zxd, p7, pi);
            Vector2 p20 = fun.PointRotate(zxd, p8, pi);
            Vector2 p21 = fun.PointRotate(zxd, p9, pi);
            Vector2 p22 = fun.PointRotate(zxd, p10, pi);
            Vector2 p23 = fun.PointRotate(zxd, p11, pi);
            Vector2 p23_ = fun.Polar(p23, pi / 2, 50);
            Vector2 p23_1 = fun.Inters(p8, p21, p23, p23_);
            Vector2 p24 = fun.PointRotate(zxd, p12, pi);
            Vector2 p33;
            Vector2 p34;
            Vector2 p35;
            Vector2 p36;
            if (R != 0)
            {
                double ang1 = fun.CalAngle(p5, p8);
                double p31j = fun.CalDistance(p5, p8);
                Vector2 p31 = fun.Polar(p5, ang1, p31j / 2);
                Vector2 p32 = fun.Polar(p31, ang1 + pi / 2, 100);
                Arc arc5 = fun.DrawArc(fun.Polar(p5, 0, R), p5, fun.Polar(p5, pi / 2, R));
                p33 = fun.Inters1(p31, p32, arc5, 0);

            }
            else
            {

                p33 = fun.Polar(p1, 0, 10);
            }
            p34 = fun.mirrorpoint(p33, zx1, zx2);
            p35 = fun.mirrorpoint(p33, fun.Polar(p1, 0, fun.CalDistance(p1, p13) / 2), fun.Polar(fun.Polar(p1, 0, fun.CalDistance(p1, p13) / 2), 90 * pi / 180, 10));
            p36 = fun.mirrorpoint(p34, fun.Polar(p1, 0, fun.CalDistance(p1, p13) / 2), fun.Polar(fun.Polar(p1, 0, fun.CalDistance(p1, p13) / 2), 90 * pi / 180, 10));


            Arc arc10 = fun.DrawArc(p2, p33, p8);
            Vector2 p37 = fun.Polar(p2, pi / 2, d * 1.0 / 5.0);



            if (d2 == 0 && R == 0)
            {
                LwPolyline poly1 = new LwPolyline();
                poly1.Vertexes.Add(new LwPolylineVertex(p11));
                poly1.Vertexes[0].Bulge = Math.Tan((0.64317749) / 4);
                poly1.Vertexes.Add(new LwPolylineVertex(p8));
                poly1.Vertexes.Add(new LwPolylineVertex(p5));

                poly1.Vertexes.Add(new LwPolylineVertex(p7));
                poly1.Vertexes.Add(new LwPolylineVertex(p10));
                poly1.Vertexes.Add(new LwPolylineVertex(p1));
                poly1.Vertexes.Add(new LwPolylineVertex(p2));
                poly1.Vertexes.Add(new LwPolylineVertex(p5));
                poly1.Vertexes.Add(new LwPolylineVertex(p2));

                poly1.Vertexes.Add(new LwPolylineVertex(p4));
                poly1.Vertexes.Add(new LwPolylineVertex(p1));
                poly1.Vertexes.Add(new LwPolylineVertex(p3));
                poly1.Vertexes.Add(new LwPolylineVertex(p6));
                poly1.Vertexes.Add(new LwPolylineVertex(p9));
                poly1.Vertexes.Add(new LwPolylineVertex(p12));

                //  dxf.AddEntity(poly1);
                fun.PolyFill(dxf, poly1, 0.5, contour);
                Arc arc2 = fun.DrawArc3(p12, p11, p10);
                //dxf.AddEntity(arc2);
                fun.drawBArc(dxf, arc2, 0.5, contour);

                LwPolyline poly2 = new LwPolyline();
                poly2.Vertexes.Add(new LwPolylineVertex(p23));
                poly2.Vertexes[0].Bulge = Math.Tan((0.64317749) / 4);
                poly2.Vertexes.Add(new LwPolylineVertex(p20));
                poly2.Vertexes.Add(new LwPolylineVertex(p17));

                poly2.Vertexes.Add(new LwPolylineVertex(p19));
                poly2.Vertexes.Add(new LwPolylineVertex(p22));
                poly2.Vertexes.Add(new LwPolylineVertex(p13));
                poly2.Vertexes.Add(new LwPolylineVertex(p14));
                poly2.Vertexes.Add(new LwPolylineVertex(p17));
                poly2.Vertexes.Add(new LwPolylineVertex(p14));

                poly2.Vertexes.Add(new LwPolylineVertex(p16));
                poly2.Vertexes.Add(new LwPolylineVertex(p13));
                poly2.Vertexes.Add(new LwPolylineVertex(p15));
                poly2.Vertexes.Add(new LwPolylineVertex(p18));
                poly2.Vertexes.Add(new LwPolylineVertex(p21));
                poly2.Vertexes.Add(new LwPolylineVertex(p24));
                //dxf.AddEntity(poly2);
                fun.PolyFill(dxf, poly2, 0.5, contour);
                Arc arc3 = fun.DrawArc3(p24, p23, p22);
                // dxf.AddEntity(arc3);
                fun.drawBArc(dxf, arc3, 0.5, contour); ;

                LwPolyline poly3 = new LwPolyline();
                poly3.Vertexes.Add(new LwPolylineVertex(p5));
                poly3.Vertexes.Add(new LwPolylineVertex(p2));
                poly3.Vertexes.Add(new LwPolylineVertex(p1));
                poly3.Vertexes.Add(new LwPolylineVertex(p3));
                poly3.Vertexes.Add(new LwPolylineVertex(p6));
                poly3.Vertexes.Add(new LwPolylineVertex(p9));
                poly3.Vertexes.Add(new LwPolylineVertex(p20));
                poly3.Vertexes.Add(new LwPolylineVertex(p17));
                poly3.Vertexes.Add(new LwPolylineVertex(p14));
                poly3.Vertexes.Add(new LwPolylineVertex(p13));
                poly3.Vertexes.Add(new LwPolylineVertex(p15));
                poly3.Vertexes.Add(new LwPolylineVertex(p18));
                poly3.Vertexes.Add(new LwPolylineVertex(p21));
                poly3.Vertexes.Add(new LwPolylineVertex(p8));
                poly3.Vertexes.Add(new LwPolylineVertex(p5));
                dxf.AddEntity(poly3);
                fun.PolyFill(dxf, poly3, 0.5, contour);
            }
            else if (d2 != 0)
            {
                LwPolyline poly1 = new LwPolyline();
                poly1.Vertexes.Add(new LwPolylineVertex(p11));
                poly1.Vertexes[0].Bulge = Math.Tan((0.63924589) / 4);
                poly1.Vertexes.Add(new LwPolylineVertex(p8));
                poly1.Vertexes.Add(new LwPolylineVertex(p25));

                poly1.Vertexes.Add(new LwPolylineVertex(p29));

                poly1.Vertexes.Add(new LwPolylineVertex(p25));
                poly1.Vertexes.Add(new LwPolylineVertex(p5));
                poly1.Vertexes.Add(new LwPolylineVertex(p7));
                poly1.Vertexes.Add(new LwPolylineVertex(p10));
                poly1.Vertexes.Add(new LwPolylineVertex(p1));
                poly1.Vertexes.Add(new LwPolylineVertex(p2));
                poly1.Vertexes.Add(new LwPolylineVertex(p5));
                poly1.Vertexes.Add(new LwPolylineVertex(p2));
                poly1.Vertexes.Add(new LwPolylineVertex(p4));
                poly1.Vertexes.Add(new LwPolylineVertex(p1));
                poly1.Vertexes.Add(new LwPolylineVertex(p3));
                poly1.Vertexes.Add(new LwPolylineVertex(p6));
                poly1.Vertexes.Add(new LwPolylineVertex(p26));
                poly1.Vertexes.Add(new LwPolylineVertex(p9));
                poly1.Vertexes.Add(new LwPolylineVertex(p12));

                // dxf.AddEntity(poly1);
                fun.PolyFill(dxf, poly1, 0.5, contour);
                Arc arc2 = fun.DrawArc3(p12, p11, p10);
                // dxf.AddEntity(arc2);
                fun.drawBArc(dxf, arc2, 0.5, contour);

                LwPolyline poly2 = new LwPolyline();
                poly2.Vertexes.Add(new LwPolylineVertex(p23));
                poly2.Vertexes[0].Bulge = Math.Tan((0.63924589) / 4);
                poly2.Vertexes.Add(new LwPolylineVertex(p20));
                poly2.Vertexes.Add(new LwPolylineVertex(p27));

                poly2.Vertexes.Add(new LwPolylineVertex(p30));

                poly2.Vertexes.Add(new LwPolylineVertex(p27));
                poly2.Vertexes.Add(new LwPolylineVertex(p17));

                poly2.Vertexes.Add(new LwPolylineVertex(p19));
                poly2.Vertexes.Add(new LwPolylineVertex(p22));

                poly2.Vertexes.Add(new LwPolylineVertex(p13));
                poly2.Vertexes.Add(new LwPolylineVertex(p14));
                poly2.Vertexes.Add(new LwPolylineVertex(p17));
                poly2.Vertexes.Add(new LwPolylineVertex(p14));

                poly2.Vertexes.Add(new LwPolylineVertex(p16));
                poly2.Vertexes.Add(new LwPolylineVertex(p13));
                poly2.Vertexes.Add(new LwPolylineVertex(p15));
                poly2.Vertexes.Add(new LwPolylineVertex(p18));
                poly2.Vertexes.Add(new LwPolylineVertex(p28));
                poly2.Vertexes.Add(new LwPolylineVertex(p21));
                poly2.Vertexes.Add(new LwPolylineVertex(p24));
                //dxf.AddEntity(poly2);
                fun.PolyFill(dxf, poly2, 0.5, contour);
                Arc arc3 = fun.DrawArc3(p24, p23, p22);
                // dxf.AddEntity(arc3);
                fun.drawBArc(dxf, arc3, 0.5, contour);

                LwPolyline poly3 = new LwPolyline();
                poly3.Vertexes.Add(new LwPolylineVertex(p5));
                poly3.Vertexes.Add(new LwPolylineVertex(p2));
                poly3.Vertexes.Add(new LwPolylineVertex(p1));
                poly3.Vertexes.Add(new LwPolylineVertex(p3));
                poly3.Vertexes.Add(new LwPolylineVertex(p6));
                poly3.Vertexes.Add(new LwPolylineVertex(p26));
                poly3.Vertexes.Add(new LwPolylineVertex(p9));
                poly3.Vertexes.Add(new LwPolylineVertex(p20));
                poly3.Vertexes.Add(new LwPolylineVertex(p27));
                poly3.Vertexes.Add(new LwPolylineVertex(p17));
                poly3.Vertexes.Add(new LwPolylineVertex(p14));
                poly3.Vertexes.Add(new LwPolylineVertex(p13));
                poly3.Vertexes.Add(new LwPolylineVertex(p15));
                poly3.Vertexes.Add(new LwPolylineVertex(p18));
                poly3.Vertexes.Add(new LwPolylineVertex(p28));
                poly3.Vertexes.Add(new LwPolylineVertex(p21));
                poly3.Vertexes.Add(new LwPolylineVertex(p8));
                poly3.Vertexes.Add(new LwPolylineVertex(p25));
                poly3.Vertexes.Add(new LwPolylineVertex(p5));
                dxf.AddEntity(poly3);
                fun.PolyFill(dxf, poly3, 0.5, contour);
            }
            else
            {
                LwPolyline poly1 = new LwPolyline();
                poly1.Vertexes.Add(new LwPolylineVertex(p11));
                poly1.Vertexes[0].Bulge = Math.Tan((0.63924589) / 4);
                poly1.Vertexes.Add(new LwPolylineVertex(p8));

                // dxf.AddEntity(poly1);
                fun.PolyFill(dxf, poly1, 0.5, contour);


                LwPolyline poly11 = new LwPolyline();
                poly11.Vertexes.Add(new LwPolylineVertex(p10));
                poly11.Vertexes.Add(new LwPolylineVertex(p1));
                poly11.Vertexes.Add(new LwPolylineVertex(p4));
                poly11.Vertexes.Add(new LwPolylineVertex(p2));
                poly11.Vertexes.Add(new LwPolylineVertex(p1));
                poly11.Vertexes.Add(new LwPolylineVertex(p3));
                //dxf.AddEntity(poly11);
                fun.PolyFill(dxf, poly11, 0.5, contour);









                Arc arc2 = fun.DrawArc3(p12, p11, p10);
                // dxf.AddEntity(arc2);
                fun.drawBArc(dxf, arc2, 0.5, contour);

                Arc arc6 = fun.DrawArc(p5, p33, p8);
                // dxf.AddEntity(arc6);

                fun.drawBArc(dxf, arc6, 0.5, contour);
                Line line1_1 = new Line(p2, p5);
                fun.drawBline(dxf, line1_1, 0.5, contour);
                Arc arc7 = fun.DrawArc(p9, p34, p6);
                //dxf.AddEntity(arc7);
                fun.drawBArc(dxf, arc7, 0.5, contour);
                Line line1_2 = new Line(p3, p6);
                fun.drawBline(dxf, line1_2, 0.5, contour);
                Arc arc8 = fun.DrawArc(p17, p36, p20);
                //   dxf.AddEntity(arc8);
                fun.drawBArc(dxf, arc8, 0.5, contour);


                Line line1_3 = new Line(p17, p14);
                fun.drawBline(dxf, line1_3, 0.5, contour);
                Arc arc9 = fun.DrawArc(p21, p35, p18);
                // dxf.AddEntity(arc9);
                fun.drawBArc(dxf, arc9, 0.5, contour); ;
                Line line1_4 = new Line(p18, p15);
                fun.drawBline(dxf, line1_4, 0.5, contour);


                LwPolyline poly2 = new LwPolyline();
                poly2.Vertexes.Add(new LwPolylineVertex(p23));
                poly2.Vertexes[0].Bulge = Math.Tan((0.63924589) / 4);
                poly2.Vertexes.Add(new LwPolylineVertex(p20));
                //dxf.AddEntity(poly2);
                fun.PolyFill(dxf, poly2, 0.5, contour);

                LwPolyline poly22 = new LwPolyline();
                poly22.Vertexes.Add(new LwPolylineVertex(p22));
                poly22.Vertexes.Add(new LwPolylineVertex(p13));
                poly22.Vertexes.Add(new LwPolylineVertex(p16));
                poly22.Vertexes.Add(new LwPolylineVertex(p14));
                poly22.Vertexes.Add(new LwPolylineVertex(p13));
                poly22.Vertexes.Add(new LwPolylineVertex(p15));
                //dxf.AddEntity(poly22);
                fun.PolyFill(dxf, poly22, 0.5, contour);



                Arc arc3 = fun.DrawArc3(p24, p23, p22);
                // dxf.AddEntity(arc3);
                fun.drawBArc(dxf, arc3, 0.5, contour); ;



                Line line1_ = new Line(p8, p21);
                Line line2_ = new Line(p9, p20);
                fun.drawBline(dxf, line1_, 0.5, contour);
                fun.drawBline(dxf, line2_, 0.5, contour);





            }
            Line line5 = new Line(zx1, zx2);
            line5.Lineweight = Lineweight.W25;//Lineweight指线宽
            line5.Layer = center;//Layer指图层
            line5.Linetype = Linetype.DashDot;//Linetype指是点划线还是虚线什么的
            dxf.AddEntity(line5);

            if (d2 == 0 && R == 0)
            {
                Vector2 p45_1 = fun.Polar(p1, pi / -2, d1 * 2);
                Vector2 p45_2 = fun.Polar(p45_1, pi, p4.X);
                fun.dimrot1(dxf, p1, p13, 180, d1 * 5, 2, 1.2 * scale, 1.6 * scale, 0.9, "  OAL="+l/scale , "", "");
                fun.dimrot1(dxf, p14, p17, 180, d1 * 2, 0, 1.2 * scale, 1.6 * scale, 0.9, "  SDL_1="+l1/scale , "", "");
                fun.dimrot1(dxf, p15, p14, -90, d1, 2, 1.2 * scale, 1.6 * scale, 0.9, "  DC_1="+d/scale , "", "");
                fun.dimrot1(dxf, p21, p20, -90, d1 * 3, 2, 1.2 * scale, 1.6 * scale, 0.9, "  DC_2="+d2/scale , "", "");
                fun.dimrot1(dxf, zxd, p14, 180, d1 * 3, 2, 1.2 * scale, 1.6 * scale, 0.9, "  LTA", "", "");
                fun.dimrot1(dxf, p1, p14, 180, d1 * 4, 2, 1.2 * scale, 1.6 * scale, 0.9, "  LF", "", "");
                fun.dimrot1(dxf, p13, p14, 180, d1 * 3, 2, 1.2 * scale, 1.6 * scale, 0.9, "  PL,SD_1", "", "");
                fun.dimrot1(dxf, p21, p13, 0, d1, 2, 1.2 * scale, 1.6 * scale, 0.9, "  SD_2", "", "");
                fun.dimrot1(dxf, p23_1, p13, 0, d1 * 2, 2, 1.2 * scale, 1.6 * scale, 0.9, "  LU", "", "");
                fun.dimrot1(dxf, p24, p13, 0, d1 * 3, 2, 1.2 * scale, 1.6 * scale, 0.9, "  LCF", "", "");
                fun.dimrot1(dxf, fun.Polar(zxd, pi / 2, d1 / 2.0), p13, 0, d1 * 4, 2, 1.2 * scale, 1.6 * scale, 0.9, "  LPR", "", "");
                fun.dimrot1(dxf, p8, p9, 90, d1 * 3, 2, 1.2 * scale, 1.6 * scale, 0.9, "  DCONMS="+d1/scale , "", "");

                fun.Axis(dxf, p45_2, 180, -90, "Z", "X", "Y", 0.5 * scale, 1.2 * scale, 0);
                fun.Axis(dxf, p1, 180, -90, "", "", "", 0.5 * scale, 1.2 * scale, 0);
                fun.Axis(dxf, p13, 180, -90, "", "", "", 0.5 * scale, 1.2 * scale, 0);
                fun.Axis(dxf, zxd, 180, -90, "", "", "", 0.5 * scale, 1.2 * scale, 0);
                fun.jdbz2(dxf, new Line(p13, fun.Polar(p13, pi / -3, 0.1)), new Line(p13, fun.Polar(p13, pi / 3, 0.1)), d1 * 3, 1.2 * scale, 1.6 * scale, 0.9, "SIG,STA_1", "", "");

                Vector2 p45 = fun.Polar(p1, pi + pi / 3, 1.7 * 0.5 + 0.3);
                Vector2 p46 = fun.Polar(p45, pi + pi / 3, d1);
                Vector2 p47 = fun.Polar(p46, pi / -2, 1.2);

                Vector2 p48 = fun.Polar(zxd, pi + pi / 4, 1.7 * 0.5 + 0.3);
                Vector2 p49 = fun.Polar(p48, pi + pi / 4, d1);
                Vector2 p50 = fun.Polar(p49, pi / -2, 1.2);

                Circle circle1 = new Circle(p14, 1.7 * 0.5);
                Vector2 p51 = fun.Polar(p14, pi + pi / 4, 1.7 * 0.5 + 0.3);
                Vector2 p52 = fun.Polar(p51, pi + pi / 4, d1);
                Vector2 p53 = fun.Polar(p52, pi / -2, 1.2);

                Vector2 p54 = fun.Polar(p13, -pi / 4, 1.7 + 0.3);
                Vector2 p55 = fun.Polar(p54, -pi / 4, d1);
                Vector2 p56 = fun.Polar(p55, pi / -2, 1.2);

                Vector2 p57 = fun.Polar(zxd, pi / 2, d1 * 5);
                Vector2 p58 = new Vector2(p13.X + d1 / 2.0 + d + d / 2.0, -d1 * 4);
                Vector2 p59 = new Vector2(p13.X + d1 / 2.0 + d / 2.0, -d1 * 4);
                Vector2 p60 = new Vector2(p13.X + d1 / 2.0, -d1 * 4);
                Line line1 = new Line(p45, p46);
                Text txt1 = new Text("PCS", p47, 1.2, 0);
                Line line2 = new Line(p48, p49);
                Text txt2 = new Text("MCS", p50, 1.2, 0);
                Line line3 = new Line(p51, p52);
                Text txt3 = new Text("CRP", p53, 1.2, 0);
                Line line4 = new Line(p54, p55);
                Text txt4 = new Text("CIP", p56, 1.2, 0);
                Text txt5 = new Text("ISYC=302_07 Type A", p57, 1.2, 0);
                fun.Singlelinearrow(dxf, "FDP", p58, 0, p59, p60, 1.2, 1.6);
                dxf.AddEntity(new EntityObject[] { circle1, line1, line2, line3, line4, txt1, txt2, txt3, txt4, txt5 });


                DimensionStyle dimensionStyle = fun.CreateDimStyle();
                dimensionStyle.ArrowSize = 0.2 * scale;
                dimensionStyle.DimArrow1 = DimensionArrowhead.Closedfilled;
                dimensionStyle.DimArrow2 = DimensionArrowhead.Closedfilled;
                dimensionStyle.TextHeight = 0.5 * scale;
                double offset = d1;

                Angular2LineDimension dim1 = new Angular2LineDimension(new Line(p18, p21), new Line(p17, p20), offset * 1.5, dimensionStyle);
                dim1.UserText = "STA_2";
                dxf.AddEntity(dim1);
            }
            else if (d2 != 0)
            {

                Vector2 p45_1 = fun.Polar(p1, pi / -2, d1 * 2);
                Vector2 p45_2 = fun.Polar(p45_1, pi, p4.X);
                fun.dimrot1(dxf, p1, p13, 180, d1 * 5, 2, 1.2 * scale, 1.6 * scale, 0.9, "  OAL="+ l/scale , "", "");
                fun.dimrot1(dxf, p14, p17, 180, d1 * 2, 0, 1.2 * scale, 1.6 * scale, 0.9, "  SDL_1="+l1/scale , "", "");
                fun.dimrot1(dxf, p15, p14, -90, d1, 2, 1.2 * scale, 1.6 * scale, 0.9, "  DC_1="+d/scale , "", "");
                fun.dimrot1(dxf, p27, p28, -90, d1 * 2.2, 2, 1.2 * scale, 1.6 * scale, 0.9, "  DC_2="+d2/scale , "", "");
                fun.dimrot1(dxf, p21, p20, -90, d1 * 2.6, 2, 1.2 * scale, 1.6 * scale, 0.9, "  DC_3", "", "");
                fun.dimrot1(dxf, zxd, p14, 180, d1 * 3, 2, 1.2 * scale, 1.6 * scale, 0.9, "  LTA", "", "");
                fun.dimrot1(dxf, p1, p14, 180, d1 * 4, 2, 1.2 * scale, 1.6 * scale, 0.9, "  LF", "", "");
                fun.dimrot1(dxf, p13, p14, 180, d1 * 3, 2, 1.2 * scale, 1.6 * scale, 0.9, "  PL,SD_1", "", "");
                fun.dimrot1(dxf, p28, p13, 0, d1, 2, 1.2 * scale, 1.6 * scale, 0.9, "  SD_2", "", "");
                fun.dimrot1(dxf, p21, p13, 0, d1 * 1.3, 2, 1.2 * scale, 1.6 * scale, 0.9, "  SD_3", "", "");
                fun.dimrot1(dxf, p23_1, p13, 0, d1 * 1.5, 2, 1.2 * scale, 1.6 * scale, 0.9, "  LU", "", "");
                fun.dimrot1(dxf, p24, p13, 0, d1 * 1.7, 2, 1.2 * scale, 1.6 * scale, 0.9, "  LCF", "", "");
                fun.dimrot1(dxf, fun.Polar(zxd, pi / 2, d1 / 2.0), p13, 0, d1 * 2, 2, 1.2 * scale, 1.6 * scale, 0.9, "  LPR", "", "");
                fun.dimrot1(dxf, p8, p9, 90, d1 * 3, 2, 1.2 * scale, 1.6 * scale, 0.9, "  DCONMS="+d1/scale , "", "");

                fun.Axis(dxf, p45_2, 180, -90, "Z", "X", "Y", 0.5 * scale, 1.2 * scale, 0);
                fun.Axis(dxf, p1, 180, -90, "", "", "", 0.5 * scale, 1.2 * scale, 0);
                fun.Axis(dxf, p13, 180, -90, "", "", "", 0.5 * scale, 1.2 * scale, 0);
                fun.Axis(dxf, zxd, 180, -90, "", "", "", 0.5 * scale, 1.2 * scale, 0);
                fun.jdbz2(dxf, new Line(p13, fun.Polar(p13, pi / -3, 0.1)), new Line(p13, fun.Polar(p13, pi / 3, 0.1)), d1 * 2.5, 1.2 * scale, 1.6 * scale, 0.9, "SIG,STA_1", "", "");

                Vector2 p45 = fun.Polar(p1, pi + pi / 3, 1.7 * 0.5 + 0.3);
                Vector2 p46 = fun.Polar(p45, pi + pi / 3, d1);
                Vector2 p47 = fun.Polar(p46, pi / -2, 1.2);

                Vector2 p48 = fun.Polar(zxd, pi + pi / 4, 1.7 * 0.5 + 0.3);
                Vector2 p49 = fun.Polar(p48, pi + pi / 4, d1);
                Vector2 p50 = fun.Polar(p49, pi / -2, 1.2);

                Circle circle1 = new Circle(p14, 1.7 * 0.5);
                Vector2 p51 = fun.Polar(p14, pi + pi / 4, 1.7 * 0.5 + 0.3);
                Vector2 p52 = fun.Polar(p51, pi + pi / 4, d1);
                Vector2 p53 = fun.Polar(p52, pi / -2, 1.2);

                Vector2 p54 = fun.Polar(p13, -pi / 4, 1.7 + 0.3);
                Vector2 p55 = fun.Polar(p54, -pi / 4, d1);
                Vector2 p56 = fun.Polar(p55, pi / -2, 1.2);

                Vector2 p57 = fun.Polar(zxd, pi / 2, d1 * 2.5);
                Vector2 p58 = new Vector2(p13.X + d1 / 2.0 + d + d / 2.0, -d1 * 4);
                Vector2 p59 = new Vector2(p13.X + d1 / 2.0 + d / 2.0, -d1 * 4);
                Vector2 p60 = new Vector2(p13.X + d1 / 2.0, -d1 * 4);
                Line line1 = new Line(p45, p46);
                Text txt1 = new Text("PCS", p47, 1.2, 0);
                Line line2 = new Line(p48, p49);
                Text txt2 = new Text("MCS", p50, 1.2, 0);
                Line line3 = new Line(p51, p52);
                Text txt3 = new Text("CRP", p53, 1.2, 0);
                Line line4 = new Line(p54, p55);
                Text txt4 = new Text("CIP", p56, 1.2, 0);
                Text txt5 = new Text("ISYC=302_07 Type B", p57, 1.2, 0);
                fun.Singlelinearrow(dxf, "FDP", p58, 0, p59, p60, 1.2, 1.6);
                dxf.AddEntity(new EntityObject[] { circle1, line1, line2, line3, line4, txt1, txt2, txt3, txt4, txt5 });


                DimensionStyle dimensionStyle = fun.CreateDimStyle();
                dimensionStyle.ArrowSize = 0.2;
                dimensionStyle.DimArrow1 = DimensionArrowhead.Closedfilled;
                dimensionStyle.DimArrow2 = DimensionArrowhead.Closedfilled;
                dimensionStyle.TextHeight = 0.5;
                double offset = d1;

                Angular2LineDimension dim1 = new Angular2LineDimension(new Line(p18, p28), new Line(p17, p27), offset, dimensionStyle);
                dim1.UserText = "STA_2";
                dxf.AddEntity(dim1);

                Angular2LineDimension dim2 = new Angular2LineDimension(new Line(p28, p21), new Line(p27, p20), offset, dimensionStyle);
                dim2.UserText = "STA_3";
                dxf.AddEntity(dim2);

            }
            else if (R != 0)
            {
                Vector2 p58 = new Vector2(p13.X + d1 / 2.0 + d + d / 2.0, d1 * 2);
                Vector2 p59 = new Vector2(p13.X + d1 / 2.0 + d / 2.0, d1 * 2);
                Vector2 p60 = new Vector2(p13.X + d1 / 2.0, d1 * 2);

                Vector2 p45_1 = fun.Polar(p1, pi / -2, d1 * 1.8);
                Vector2 p45_2 = fun.Polar(p45_1, pi, p4.X);
                fun.dimrot1(dxf, p1, p13, 180, d1 * 5, 2, 1.2 * scale, 1.6 * scale, 0.9, "  OAL=" + l / scale, "", "");
                fun.dimrot1(dxf, p14, p17, 180, d1 * 2, 0, 1.2 * scale, 1.6 * scale, 0.9, "  SDL_1=" + l1 / scale, "", "");
                fun.dimrot1(dxf, p15, p14, -90, d1, 2, 1.2 * scale, 1.6 * scale, 0.9, "  DC_1=" + d / scale, "", "");
                fun.dimrot1(dxf, p21, p20, -90, d1 * 3, 2, 1.2 * scale, 1.6 * scale, 0.9, "  DC_2=" + d2 / scale, "", "");
                fun.dimrot1(dxf, zxd, p14, 180, d1 * 3, 2, 1.2 * scale, 1.6 * scale, 0.9, "  LTA", "", "");
                fun.dimrot1(dxf, p1, p14, 180, d1 * 4, 2, 1.2 * scale, 1.6 * scale, 0.9, "  LF", "", "");
                fun.dimrot1(dxf, p13, p14, 180, d1 * 3, 2, 1.2 * scale, 1.6 * scale, 0.9, "  PL,SD_1", "", "");
                fun.dimrot1(dxf, p21, p13, 0, d1, 2, 1.2 * scale, 1.6 * scale, 0.9, "  SD_2", "", "");
                fun.dimrot1(dxf, p23_1, p13, 0, d1 * 2, 2, 1.2 * scale, 1.6 * scale, 0.9, "  LU", "", "");
                fun.dimrot1(dxf, p24, p13, 0, d1 * 3, 2, 1.2 * scale, 1.6 * scale, 0.9, "  LCF", "", "");
                fun.dimrot1(dxf, fun.Polar(zxd, pi / 2, d1 / 2.0), p13, 0, d1 * 4, 2, 1.2 * scale, 1.6 * scale, 0.9, "  LPR", "", "");
                fun.dimrot1(dxf, p8, p9, 90, d1 * 3, 2, 1.2 * scale, 1.6 * scale, 0.9, "  DCONMS=" + d1 / scale, "", "");

                fun.Axis(dxf, p45_2, 180, -90, "Z", "X", "Y", 0.5 * scale, 1.2 * scale, 0);
                fun.Axis(dxf, p1, 180, -90, "", "", "", 0.5 * scale, 1.2 * scale, 0);
                fun.Axis(dxf, p13, 180, -90, "", "", "", 0.5 * scale, 1.2 * scale, 0);
                fun.Axis(dxf, zxd, 180, -90, "", "", "", 0.5 * scale, 1.2 * scale, 0);
                fun.jdbz2(dxf, new Line(p13, fun.Polar(p13, pi / -3, 0.1)), new Line(p13, fun.Polar(p13, pi / 3, 0.1)), d1 * 1.5, 1.2 * scale, 1.6 * scale, 0.9, "SIG", "", "");

                Vector2 p45 = fun.Polar(p1, pi + pi / 3, 1.7 * 0.5 + 0.3);
                Vector2 p46 = fun.Polar(p45, pi + pi / 3, d1);
                Vector2 p47 = fun.Polar(p46, pi / -2, 1.2);

                Vector2 p48 = fun.Polar(zxd, pi + pi / 4, 1.7 * 0.5 + 0.3);
                Vector2 p49 = fun.Polar(p48, pi + pi / 4, d1);
                Vector2 p50 = fun.Polar(p49, pi / -2, 1.2);

                Circle circle1 = new Circle(p14, 1.7 * 0.5);
                Vector2 p51 = fun.Polar(p14, -105 * pi / 180, 1.7 * 0.5 + 0.3);
                Vector2 p52 = fun.Polar(p51, -105 * pi / 180, d1);
                Vector2 p53 = fun.Polar(p52, pi / -2, 1.2);

                Vector2 p54 = fun.Polar(p13, -pi / 4, 1.7 + 0.3);
                Vector2 p55 = fun.Polar(p54, -pi / 4, d1);
                Vector2 p56 = fun.Polar(p55, pi / -2, 1.2);

                Vector2 p57 = fun.Polar(zxd, pi / 2, d1 * 3.3);


                Vector2 p61 = fun.Polar(p8, 0, l * (1.0 / 10));
                Vector2 p62 = fun.Polar(p61, pi - 45 * pi / 180, 10);
                Vector2 p63 = fun.Polar(p62, pi - 45 * pi / 180, 10);
                Vector2 p64 = fun.Polar(p63, pi / 2, 0.3);
                Vector2 p65 = fun.Polar(p13, pi / -2, d / 2.0 + (d1 / 2.0 - d / 2.0) / 2.0);
                Vector2 p66 = fun.Polar(p65, pi, 100);
                Arc arc8 = fun.DrawArc(p17, p36, p20);
                Vector2 p67 = fun.Inters1(p65, p66, arc8, 0);
                Vector2 p68 = fun.Polar(p67, -100 * pi / 180, 10);
                Vector2 p69 = fun.Polar(p68, -100 * pi / 180, 10);
                Vector2 p70 = fun.Polar(p68, pi / -2, 1.2 + 0.3);

                fun.Singlelinearrow(dxf, "FDP", p58, 0, p59, p60, 1.2 * scale, 1.6 * scale);



                Line line1 = new Line(p45, p46);
                Text txt1 = new Text("PCS", p47, 1.2 * scale, 0);
                Line line2 = new Line(p48, p49);
                Text txt2 = new Text("MCS", p50, 1.2 * scale, 0);
                Line line3 = new Line(p51, p52);
                Text txt3 = new Text("CRP", p53, 1.2 * scale, 0);
                Line line4 = new Line(p54, p55);
                Text txt4 = new Text("CIP", p56, 1.2 * scale, 0);
                Text txt5 = new Text("ISYC=302_07 Type R", p57, 1.2 * scale, 0);

                dxf.AddEntity(new EntityObject[] { circle1, line1, line2, line3, line4, txt1, txt2, txt3, txt4, txt5 });

                fun.Singlelinearrow(dxf, "CCMS", p61, 135, p62, p63, 1.2 * scale, 1.6);
                fun.Singlelinearrow(dxf, "RCSK_2", p67, -100, p68, p69, 1.2 * scale, 1.6);



            }
            else
            {

            }
            Vector2 p71 = fun.Polar(zxd, pi / 2, d1 / 2 + 3);
            Vector2 p72 = fun.Polar(p71, pi / 2 + pi / 4, 5);
            Vector2 p73 = fun.Polar(p72, pi, 5);
            Vector2 p74 = fun.mirrorpoint(p71, p1, p13);
            Vector2 p75 = fun.mirrorpoint(p72, p1, p13);
            Vector2 p76 = fun.mirrorpoint(p73, p1, p13);

            Line line2_1 = new Line(p73, p72);
            Line line2_2 = new Line(p72, p71);
            Line line2_3 = new Line(p71, p74);
            Line line2_4 = new Line(p74, p75);
            Line line2_5 = new Line(p75, p76);
            line2_1.Layer = additionalline;
            line2_1.Linetype = Linetype.Dashed;
            dxf.AddEntity(line2_1);

            line2_2.Layer = additionalline;
            line2_2.Linetype = Linetype.Dashed;
            dxf.AddEntity(line2_2);

            line2_3.Layer = additionalline;
            line2_3.Linetype = Linetype.Dashed;
            dxf.AddEntity(line2_3);

            line2_4.Layer = additionalline;
            line2_4.Linetype = Linetype.Dashed;
            dxf.AddEntity(line2_4);

            line2_5.Layer = additionalline;
            line2_5.Linetype = Linetype.Dashed;
            dxf.AddEntity(line2_5);


            double isframe = Convert.ToInt32(data["isframe"]);
            String isframe_chose = Convert.ToString(data["isframe_chose"]);
            Vector2 p0 = new Vector2(0, 0);
            if (isframe == 1)
            {
                if (isframe_chose.Equals("0"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA0X(dxf, new Vector2(p0.X - 1189 / 2.0, p0.Y + 841 / 2.0), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }

                if (isframe_chose.Equals("1"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA1X(dxf, new Vector2(p0.X - 841 / 2.0, p0.Y + 594 / 2.0), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }

                if (isframe_chose.Equals("2"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA2X(dxf, new Vector2(p0.X - 594 / 2.0, p0.Y + 420 / 2.0), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }

                if (isframe_chose.Equals("3"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA3X(dxf, new Vector2(p0.X - 420 / 2.0, p0.Y + 297 / 2.0), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }

                if (isframe_chose.Equals("4X"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA4X(dxf, new Vector2(p0.X - 297 / 2.0, p0.Y + 210 / 2.0 - 10 * 2.26), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }

                if (isframe_chose.Equals("4Y"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA4Y(dxf, new Vector2(p0.X - 210 / 2.0, p0.Y + 297 / 2.0), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }
            }


            fun.SetLayer(dxf);
            fun.SetByLayer(dxf);




            /*
            fun.dimrot1(dxf, p0, fun.Polar(p7, 1.08752241, l * (0.86539032 / 12.0)), 0, d, 2, 1.2, 1.6, 0.9, "  l=" + l, "", "");
            fun.jdbz2(dxf, new Line(p17, fun.Polar(p17, 0, 0.1)), new Line(p17, fun.Polar(p17, γf * pi / 180, 0.1)), d1 / 2, 1.6, 0.5, 0.9, "γf=" + γf + "°", "", "");
            */
            dxf.DrawingVariables.AcadVer = DxfVersion.AutoCad2007;
            dxf.Save(path);
        }

        public static void ISYC_302_07(Dictionary<string, Object> data)    //整体A/B/R型中心钻
        {
            DxfDocument dxf = new DxfDocument();
            dxf.Layers["0"].Lineweight = Lineweight.W25;
            Layer contour = new Layer("contour");//轮廓层
            Layer dimensioning = new Layer("dimensioning");//尺寸层
            Layer refin = new Layer("refin");//基准线/内轮廓/虚线
            Layer center = new Layer("center");//中心线
            Layer textlayer = new Layer("textlayer");//文本层
            Layer hatching = new Layer("hatching");//填充层
            Layer additionalline = new Layer("additionalline");//附加线
            Layer cutting = new Layer("cutting");//切削层
            fun.SetLayer(dxf);

            double sl = 68;
            double scale = 1;

            if (sl <= 67)
            {
                scale = 2.2;
            }
            else if (67 < sl && sl <= 75)
            {
                scale = 1.8;
            }
            else if (75 < sl && sl <= 100)
            {
                scale = 1.4;
            }
            else
            {
                scale = 1;
            }
            /*
            string path = Convert.ToString(data["path"]);
            double pi = Math.PI;
            double d = 10.0 * scale;
            double d1 = 25.0 * scale;
            double d2 = 0 * scale;
            double l = 100.0 * scale;
            double l1 = 6.5 * scale;
            double R = 15 * scale;
            double eper = 120;
            double eper_ = eper / 2 * pi / 180;
            */
            /*
             string path = Convert.ToString(data["path"]);
             double pi = Math.PI;
             double d = 5.0*scale ;
             double d1 = 12.5 * scale;
             double d2 = 0 * scale;
             double l = 63.0 * scale;
             double l1 =6.3 * scale;
             double R = 0 * scale;
             double eper = 120;
             double eper_ = eper / 2 * pi / 180;
             */
            /*
            string path = Convert.ToString(data["path"]);
            double pi = Math.PI;
            double d = 5.0*scale ;
            double d1 = 18.0 * scale;
            double d2 = 10.6 * scale;
            double l = 75 * scale;
            double l1 = 6.3 * scale;
            double R = 0 * scale;
            double eper = 120;
            double eper_ = eper / 2 * pi / 180;
            */

            string path = Convert.ToString(data["path"]);
            double pi = Math.PI;
            double d = Convert.ToDouble(data["dc1"]) * scale; ;
            double d1 = Convert.ToDouble(data["dmm"]) * scale; ;
            double d2 = Convert.ToDouble(data["dc2"]) * scale; ;
            double l = Convert.ToDouble(data["oal"]) * scale; ;
            double l1 = Convert.ToDouble(data["sdl1"]) * scale; ;
            double R = Convert.ToDouble(data["r"]) * scale; ;
            double eper = Convert.ToDouble(data["eper"]); ;
            double eper_ = eper / 2 * pi / 180;

            Vector2 zx1 = new Vector2(-5, 0);
            Vector2 zx2 = fun.Polar(zx1, 0, l + 10);
            Vector2 p1 = new Vector2(0, 0);
            Vector2 p1_ = fun.Polar(p1, 0, 50);
            Vector2 zxd = fun.Polar(p1, 0, l / 2);
            Vector2 p2 = fun.Polar(p1, eper_, (d / 2) / Math.Sin(eper_));
            Vector2 p2_ = fun.Polar(p2, pi / -2, 50);
            Vector2 p3 = fun.mirrorpoint(p2, zx1, zx2);
            Vector2 p4 = fun.Inters(p1, p1_, p2, p2_);




            Vector2 p5 = fun.Polar(fun.Polar(p1, pi / 2, d / 2), 0, l1);
            Vector2 p5_ = fun.Polar(p5, pi / -2, 50);
            Vector2 p6 = fun.mirrorpoint(p5, zx1, zx2);
            Vector2 p7 = fun.Inters(p1, p1_, p5, p5_);
            /*
            Vector2 p5_1 = fun.Polar(p5, 0, Math.Sqrt((((d1 - d) / 2) * ((d1 - d) / 2)) + ((l * (3.25757537 / 31.5)) * (l * (3.25757537 / 31.5)))));
            Vector2 p5_2 = fun.Polar(p5, pi / 2, Math.Sqrt((((d1 - d) / 2) * ((d1 - d) / 2)) + ((l * (3.25757537 / 31.5)) * (l * (3.25757537 / 31.5)))));
            System.Diagnostics.Debug.WriteLine( Math.Sqrt((((d1 - d) / 2) * ((d1 - d) / 2)) + ((l * (3.25757537 / 31.5)) * (l * (3.25757537 / 31.5)))));
            Arc arc1 = fun.DrawArc (p5_1,p5,p5_2);            
            Vector2 p8_ = fun.Polar(p1, pi / 2, d1 / 2);
            Vector2 p8 = fun.getPointForArcandLine(p8_ , fun.Polar (p8_ ,0,l), p5, arc1);
            */
            Vector2 p8;
            Vector2 p25;
            Vector2 p26;
            Vector2 p27;
            Vector2 p28;
            if (d2 == 0 && R == 0)
            {
                p25 = fun.Polar(p5, pi / 6, ((d1 - d) / 2.0 - 0.25 * scale) / Math.Sin(pi / 6));
                p26 = fun.mirrorpoint(p25, zx1, zx2);

            }

            else
            {
                p25 = fun.Polar(p5, pi / 6, d2 - d);
                p26 = fun.mirrorpoint(p25, zx1, zx2);

            }
            Vector2 p25_1 = fun.Polar(p5, pi / 6, ((d1 - d) / 2.0 - 0.5 * scale) / Math.Sin(pi / 6) / 2.0);
            Vector2 p26_1 = fun.mirrorpoint(p25_1, zx1, zx2);

            p27 = fun.PointRotate(zxd, p25, pi);
            p28 = fun.PointRotate(zxd, p26, pi);

            if (d2 == 0 && R == 0 || R != 0)
            {

                p8 = fun.Polar(p5, pi / 6, (d1 - d));

            }
            else
            {

                p8 = fun.Polar(p25, pi / 3, ((d1 - d2) / 2) / Math.Cos(pi / 6));

            }


            Vector2 p9 = fun.mirrorpoint(p8, zx1, zx2);
            Vector2 p9_ = fun.Polar(p9, 1.81100631, 50);
            Vector2 p10 = fun.Inters(p9, p9_, zx1, zx2);
            Vector2 p11;
            Vector2 p12;
            Vector2 p25_ = fun.Polar(p25, pi / -2, 50);
            Vector2 p29 = fun.Inters(p25, p25_, p1, p1_);
            Vector2 p30 = fun.PointRotate(zxd, p29, pi);


            p11 = fun.Polar(p9, 1.17825328, d1 * (1.68721823 / 4));
            p12 = fun.Polar(p9, 0, d1 * (2.21864798 / 4));




            Vector2 p13 = fun.Polar(p1, 0, l);
            Vector2 p14 = fun.PointRotate(zxd, p2, pi);
            Vector2 p15 = fun.PointRotate(zxd, p3, pi);
            Vector2 p16 = fun.PointRotate(zxd, p4, pi);
            Vector2 p17 = fun.PointRotate(zxd, p5, pi);
            Vector2 p18 = fun.PointRotate(zxd, p6, pi);
            Vector2 p19 = fun.PointRotate(zxd, p7, pi);
            Vector2 p20 = fun.PointRotate(zxd, p8, pi);
            Vector2 p21 = fun.PointRotate(zxd, p9, pi);
            Vector2 p22 = fun.PointRotate(zxd, p10, pi);
            Vector2 p23 = fun.PointRotate(zxd, p11, pi);
            Vector2 p23_ = fun.Polar(p23, pi / 2, 50);
            Vector2 p23_1 = fun.Inters(p8, p21, p23, p23_);
            Vector2 p24 = fun.PointRotate(zxd, p12, pi);
            Vector2 p33;
            Vector2 p34;
            Vector2 p35;
            Vector2 p36;
            if (R != 0)
            {
                double ang1 = fun.CalAngle(p5, p8);
                double p31j = fun.CalDistance(p5, p8);
                Vector2 p31 = fun.Polar(p5, ang1, p31j / 2);
                Vector2 p32 = fun.Polar(p31, ang1 + pi / 2, 100);
                Arc arc5 = fun.DrawArc(fun.Polar(p5, 0, R), p5, fun.Polar(p5, pi / 2, R));
                p33 = fun.Inters1(p31, p32, arc5, 0);

            }
            else
            {

                p33 = fun.Polar(p1, 0, 10);
            }
            p34 = fun.mirrorpoint(p33, zx1, zx2);
            p35 = fun.mirrorpoint(p33, fun.Polar(p1, 0, fun.CalDistance(p1, p13) / 2), fun.Polar(fun.Polar(p1, 0, fun.CalDistance(p1, p13) / 2), 90 * pi / 180, 10));
            p36 = fun.mirrorpoint(p34, fun.Polar(p1, 0, fun.CalDistance(p1, p13) / 2), fun.Polar(fun.Polar(p1, 0, fun.CalDistance(p1, p13) / 2), 90 * pi / 180, 10));


            Arc arc10 = fun.DrawArc(p2, p33, p8);
            Vector2 p37 = fun.Polar(p2, pi / 2, d * 1.0 / 5.0);



            if (d2 == 0 && R == 0)
            {
                LwPolyline poly1 = new LwPolyline();
                poly1.Vertexes.Add(new LwPolylineVertex(p8));
                poly1.Vertexes.Add(new LwPolylineVertex(p25));
                poly1.Vertexes.Add(new LwPolylineVertex(p26));
                poly1.Vertexes.Add(new LwPolylineVertex(p9));
                poly1.Vertexes.Add(new LwPolylineVertex(p8));
                //  dxf.AddEntity(poly1);
                fun.PolyFill(dxf, poly1, 0.5, contour);

                LwPolyline poly2 = new LwPolyline();
                poly2.Vertexes.Add(new LwPolylineVertex(p23));
                poly2.Vertexes[0].Bulge = Math.Tan((0.64317749) / 4);
                poly2.Vertexes.Add(new LwPolylineVertex(p20));
                poly2.Vertexes.Add(new LwPolylineVertex(p17));
                poly2.Vertexes.Add(new LwPolylineVertex(p19));
                poly2.Vertexes.Add(new LwPolylineVertex(p22));
                poly2.Vertexes.Add(new LwPolylineVertex(p13));
                poly2.Vertexes.Add(new LwPolylineVertex(p14));
                poly2.Vertexes.Add(new LwPolylineVertex(p17));
                poly2.Vertexes.Add(new LwPolylineVertex(p14));
                poly2.Vertexes.Add(new LwPolylineVertex(p16));
                poly2.Vertexes.Add(new LwPolylineVertex(p13));
                poly2.Vertexes.Add(new LwPolylineVertex(p15));
                poly2.Vertexes.Add(new LwPolylineVertex(p18));
                poly2.Vertexes.Add(new LwPolylineVertex(p21));
                poly2.Vertexes.Add(new LwPolylineVertex(p24));
                //dxf.AddEntity(poly2);
                fun.PolyFill(dxf, poly2, 0.5, contour);
                Arc arc3 = fun.DrawArc3(p24, p23, p22);
                // dxf.AddEntity(arc3);
                fun.drawBArc(dxf, arc3, 0.5, contour); ;

                LwPolyline poly3 = new LwPolyline();
                poly3.Vertexes.Add(new LwPolylineVertex(p8));
                poly3.Vertexes.Add(new LwPolylineVertex(p25));
                poly3.Vertexes.Add(new LwPolylineVertex(p26));
                poly3.Vertexes.Add(new LwPolylineVertex(p9));
                poly3.Vertexes.Add(new LwPolylineVertex(p8));
                poly3.Vertexes.Add(new LwPolylineVertex(p9));
                poly3.Vertexes.Add(new LwPolylineVertex(p20));
                poly3.Vertexes.Add(new LwPolylineVertex(p17));
                poly3.Vertexes.Add(new LwPolylineVertex(p14));
                poly3.Vertexes.Add(new LwPolylineVertex(p13));
                poly3.Vertexes.Add(new LwPolylineVertex(p15));
                poly3.Vertexes.Add(new LwPolylineVertex(p18));
                poly3.Vertexes.Add(new LwPolylineVertex(p21));
                poly3.Vertexes.Add(new LwPolylineVertex(p8));
                dxf.AddEntity(poly3);
                fun.PolyFill(dxf, poly3, 0.5, contour);
            }
            else if (d2 != 0)
            {
                LwPolyline poly1 = new LwPolyline();
                poly1.Vertexes.Add(new LwPolylineVertex(p8));
                poly1.Vertexes.Add(new LwPolylineVertex(p25_1));
                poly1.Vertexes.Add(new LwPolylineVertex(p26_1));
                poly1.Vertexes.Add(new LwPolylineVertex(p9));
                poly1.Vertexes.Add(new LwPolylineVertex(p8));
                //  dxf.AddEntity(poly1);
                fun.PolyFill(dxf, poly1, 0.5, contour);

                LwPolyline poly2 = new LwPolyline();
                poly2.Vertexes.Add(new LwPolylineVertex(p23));
                poly2.Vertexes[0].Bulge = Math.Tan((0.64317749) / 4);
                poly2.Vertexes.Add(new LwPolylineVertex(p20));
                poly2.Vertexes.Add(new LwPolylineVertex(p27));
                poly2.Vertexes.Add(new LwPolylineVertex(p17));
                poly2.Vertexes.Add(new LwPolylineVertex(p19));
                poly2.Vertexes.Add(new LwPolylineVertex(p22));
                poly2.Vertexes.Add(new LwPolylineVertex(p13));
                poly2.Vertexes.Add(new LwPolylineVertex(p14));
                poly2.Vertexes.Add(new LwPolylineVertex(p17));
                poly2.Vertexes.Add(new LwPolylineVertex(p14));
                poly2.Vertexes.Add(new LwPolylineVertex(p16));
                poly2.Vertexes.Add(new LwPolylineVertex(p13));
                poly2.Vertexes.Add(new LwPolylineVertex(p15));
                poly2.Vertexes.Add(new LwPolylineVertex(p18));
                poly2.Vertexes.Add(new LwPolylineVertex(p28));
                poly2.Vertexes.Add(new LwPolylineVertex(p21));
                poly2.Vertexes.Add(new LwPolylineVertex(p24));
                //dxf.AddEntity(poly2);
                fun.PolyFill(dxf, poly2, 0.5, contour);
                Arc arc3 = fun.DrawArc3(p24, p23, p22);
                // dxf.AddEntity(arc3);
                fun.drawBArc(dxf, arc3, 0.5, contour);

                LwPolyline poly3 = new LwPolyline();
                poly3.Vertexes.Add(new LwPolylineVertex(p8));
                poly3.Vertexes.Add(new LwPolylineVertex(p25_1));
                poly3.Vertexes.Add(new LwPolylineVertex(p26_1));
                poly3.Vertexes.Add(new LwPolylineVertex(p9));
                poly3.Vertexes.Add(new LwPolylineVertex(p8));
                poly3.Vertexes.Add(new LwPolylineVertex(p9));
                poly3.Vertexes.Add(new LwPolylineVertex(p20));
                poly3.Vertexes.Add(new LwPolylineVertex(p27));
                poly3.Vertexes.Add(new LwPolylineVertex(p17));
                poly3.Vertexes.Add(new LwPolylineVertex(p14));
                poly3.Vertexes.Add(new LwPolylineVertex(p13));
                poly3.Vertexes.Add(new LwPolylineVertex(p15));
                poly3.Vertexes.Add(new LwPolylineVertex(p18));
                poly3.Vertexes.Add(new LwPolylineVertex(p28));
                poly3.Vertexes.Add(new LwPolylineVertex(p21));
                poly3.Vertexes.Add(new LwPolylineVertex(p8));
                dxf.AddEntity(poly3);
                fun.PolyFill(dxf, poly3, 0.5, contour);
            }
            else
            {
                LwPolyline poly1 = new LwPolyline();
                poly1.Vertexes.Add(new LwPolylineVertex(p11));
                poly1.Vertexes[0].Bulge = Math.Tan((0.63924589) / 4);
                poly1.Vertexes.Add(new LwPolylineVertex(p8));

                // dxf.AddEntity(poly1);
                fun.PolyFill(dxf, poly1, 0.5, contour);

                LwPolyline poly11 = new LwPolyline();
                poly11.Vertexes.Add(new LwPolylineVertex(p10));
                poly11.Vertexes.Add(new LwPolylineVertex(p1));
                poly11.Vertexes.Add(new LwPolylineVertex(p4));
                poly11.Vertexes.Add(new LwPolylineVertex(p2));
                poly11.Vertexes.Add(new LwPolylineVertex(p1));
                poly11.Vertexes.Add(new LwPolylineVertex(p3));
                //dxf.AddEntity(poly11);
                fun.PolyFill(dxf, poly11, 0.5, contour);

                Arc arc2 = fun.DrawArc3(p12, p11, p10);
                // dxf.AddEntity(arc2);
                fun.drawBArc(dxf, arc2, 0.5, contour);

                Arc arc6 = fun.DrawArc(p5, p33, p8);
                // dxf.AddEntity(arc6);

                fun.drawBArc(dxf, arc6, 0.5, contour);
                Line line1_1 = new Line(p2, p5);
                fun.drawBline(dxf, line1_1, 0.5, contour);
                Arc arc7 = fun.DrawArc(p9, p34, p6);
                //dxf.AddEntity(arc7);
                fun.drawBArc(dxf, arc7, 0.5, contour);
                Line line1_2 = new Line(p3, p6);
                fun.drawBline(dxf, line1_2, 0.5, contour);
                Arc arc8 = fun.DrawArc(p17, p36, p20);
                //   dxf.AddEntity(arc8);
                fun.drawBArc(dxf, arc8, 0.5, contour);

                Line line1_3 = new Line(p17, p14);
                fun.drawBline(dxf, line1_3, 0.5, contour);
                Arc arc9 = fun.DrawArc(p21, p35, p18);
                // dxf.AddEntity(arc9);
                fun.drawBArc(dxf, arc9, 0.5, contour); ;
                Line line1_4 = new Line(p18, p15);
                fun.drawBline(dxf, line1_4, 0.5, contour);

                LwPolyline poly2 = new LwPolyline();
                poly2.Vertexes.Add(new LwPolylineVertex(p23));
                poly2.Vertexes[0].Bulge = Math.Tan((0.63924589) / 4);
                poly2.Vertexes.Add(new LwPolylineVertex(p20));
                //dxf.AddEntity(poly2);
                fun.PolyFill(dxf, poly2, 0.5, contour);

                LwPolyline poly22 = new LwPolyline();
                poly22.Vertexes.Add(new LwPolylineVertex(p22));
                poly22.Vertexes.Add(new LwPolylineVertex(p13));
                poly22.Vertexes.Add(new LwPolylineVertex(p16));
                poly22.Vertexes.Add(new LwPolylineVertex(p14));
                poly22.Vertexes.Add(new LwPolylineVertex(p13));
                poly22.Vertexes.Add(new LwPolylineVertex(p15));
                //dxf.AddEntity(poly22);
                fun.PolyFill(dxf, poly22, 0.5, contour);

                Arc arc3 = fun.DrawArc3(p24, p23, p22);
                // dxf.AddEntity(arc3);
                fun.drawBArc(dxf, arc3, 0.5, contour); ;

                Line line1_ = new Line(p8, p21);
                Line line2_ = new Line(p9, p20);
                fun.drawBline(dxf, line1_, 0.5, contour);
                fun.drawBline(dxf, line2_, 0.5, contour);

            }
            Line line5 = new Line(zx1, zx2);
            line5.Lineweight = Lineweight.W25;//Lineweight指线宽
            line5.Layer = center;//Layer指图层
            line5.Linetype = Linetype.DashDot;//Linetype指是点划线还是虚线什么的
            dxf.AddEntity(line5);

            if (d2 == 0 && R == 0)
            {
                Vector2 p45_1 = fun.Polar(p1, pi / -2, d1 * 2);
                Vector2 p45_2 = fun.Polar(p45_1, pi, p4.X);
                fun.dimrot1(dxf, p25, p13, 0, d1 * 3, 2, 1.2 * scale, 1.6 * scale, 0.9, "  OAL", "", "");
                fun.dimrot1(dxf, p14, p17, 0, d1 + (d1 - d) / 2.0, 0, 1.2 * scale, 1.6 * scale, 0.9, "  SDL_1", "", "");
                fun.dimrot1(dxf, p15, p14, -90, d1, 2, 1.2 * scale, 1.6 * scale, 0.9, "  DC_1", "", "");
                fun.dimrot1(dxf, p21, p20, -90, d1 * 3, 2, 1.2 * scale, 1.6 * scale, 0.9, "  DC_2", "", "");
                fun.dimrot1(dxf, p26, fun.Polar(p24, pi, fun.CalDistance(p8, p24) / 10.0), 180, d1 * 1.4, 2, 1.2 * scale, 1.6 * scale, 0.9, "  LS", "", "");
                fun.dimrot1(dxf, p21, p13, 0, d1 * 1.4, 2, 1.2 * scale, 1.6 * scale, 0.9, "  SD_2", "", "");
                fun.dimrot1(dxf, p23_1, p13, 0, d1 * 1.8, 2, 1.2 * scale, 1.6 * scale, 0.9, "  LU", "", "");
                fun.dimrot1(dxf, p24, p13, 0, d1 * 2.2, 2, 1.2 * scale, 1.6 * scale, 0.9, "  LCF", "", "");
                fun.dimrot1(dxf, fun.Polar(zxd, pi / 2, d1 / 2.0), p13, 0, d1 * 2.6, 2, 1.2 * scale, 1.6 * scale, 0.9, "  LPR", "", "");
                fun.dimrot1(dxf, p8, p9, 90, d1 * 3, 2, 1.2 * scale, 1.6 * scale, 0.9, "  DCONMS", "", "");

                fun.jdbz2(dxf, new Line(p13, fun.Polar(p13, pi / -3, 0.1)), new Line(p13, fun.Polar(p13, pi / 3, 0.1)), d1 * 1.5, 1.2 * scale, 1.6 * scale, 0.9, "SIG", "", "");

                Vector2 p58 = new Vector2(p13.X + d1 / 2.0 + d + d / 2.0, -d1 * 4);
                Vector2 p59 = new Vector2(p13.X + d1 / 2.0 + d / 2.0, -d1 * 4);
                Vector2 p60 = new Vector2(p13.X + d1 / 2.0, -d1 * 4);

                DimensionStyle dimensionStyle = fun.CreateDimStyle();
                dimensionStyle.ArrowSize = 0.2 * scale;
                dimensionStyle.DimArrow1 = DimensionArrowhead.Closedfilled;
                dimensionStyle.DimArrow2 = DimensionArrowhead.Closedfilled;
                dimensionStyle.TextHeight = 0.5 * scale;
                double offset = d1;

                Angular2LineDimension dim1 = new Angular2LineDimension(new Line(p18, p21), new Line(p17, p20), offset * 1.5, dimensionStyle);
                dim1.UserText = "STA_2";
                dxf.AddEntity(dim1);
            }
            else if (d2 != 0)
            {




                fun.dimrot1(dxf, fun.Polar(p25_1, pi / -2, fun.CalDistance(p25_1, p26_1) / 2.0), p13, 0, d1 * 2.4, 2, 1.2 * scale, 1.6 * scale, 0.9, "  OAL", "", "");
                fun.dimrot1(dxf, p14, p17, 0, d1, 0, 1.2 * scale, 1.6 * scale, 0.9, "  SDL_1", "", "");
                fun.dimrot1(dxf, p15, p14, -90, d1, 2, 1.2 * scale, 1.6 * scale, 0.9, "  DC_1", "", "");
                fun.dimrot1(dxf, p21, p20, -90, d1 * 2.6, 2, 1.2 * scale, 1.6 * scale, 0.9, "  DC_2", "", "");
                fun.dimrot1(dxf, p26_1, fun.Polar(p24, pi, fun.CalDistance(p8, p24) / 10.0), 180, d1 * 1.5, 2, 1.2 * scale, 1.6 * scale, 0.9, "  LS", "", "");
                fun.dimrot1(dxf, p21, p13, 0, d1 * 1.3, 2, 1.2 * scale, 1.6 * scale, 0.9, "  SD_2", "", "");
                fun.dimrot1(dxf, p23_1, p13, 0, d1 * 1.5, 2, 1.2 * scale, 1.6 * scale, 0.9, "  LU", "", "");
                fun.dimrot1(dxf, p24, p13, 0, d1 * 1.7, 2, 1.2 * scale, 1.6 * scale, 0.9, "  LCF", "", "");
                fun.dimrot1(dxf, fun.Polar(zxd, pi / 2, d1 / 2.0), p13, 0, d1 * 2, 2, 1.2 * scale, 1.6 * scale, 0.9, "  LPR", "", "");
                fun.dimrot1(dxf, p8, p9, 90, d1, 2, 1.2 * scale, 1.6 * scale, 0.9, "  DMM", "", "");
                fun.jdbz2(dxf, new Line(p13, fun.Polar(p13, pi / -3, 0.1)), new Line(p13, fun.Polar(p13, pi / 3, 0.1)), d1 * 1.3, 1.2 * scale, 1.6 * scale, 0.9, "SIG", "", "");

                Vector2 p58 = new Vector2(p13.X + d1 / 2.0 + d + d / 2.0, -d1 * 4);
                Vector2 p59 = new Vector2(p13.X + d1 / 2.0 + d / 2.0, -d1 * 4);
                Vector2 p60 = new Vector2(p13.X + d1 / 2.0, -d1 * 4);

                DimensionStyle dimensionStyle = fun.CreateDimStyle();
                dimensionStyle.ArrowSize = 0.2;
                dimensionStyle.DimArrow1 = DimensionArrowhead.Closedfilled;
                dimensionStyle.DimArrow2 = DimensionArrowhead.Closedfilled;
                dimensionStyle.TextHeight = 0.5;
                double offset = d1 / 1.2;

                Angular2LineDimension dim1 = new Angular2LineDimension(new Line(p18, p28), new Line(p17, p27), offset, dimensionStyle);
                dim1.UserText = "SIGCSK";
                dxf.AddEntity(dim1);

                Angular2LineDimension dim2 = new Angular2LineDimension(new Line(p28, p21), new Line(p27, p20), offset, dimensionStyle);
                dim2.UserText = "STA_2";
                dxf.AddEntity(dim2);

            }
            else if (R != 0)
            {

                Vector2 p45_1 = fun.Polar(p1, pi / -2, d1 * 1.8);
                Vector2 p45_2 = fun.Polar(p45_1, pi, p4.X);
                fun.dimrot1(dxf, p1, p13, 0, d1 * 3, 2, 1.2 * scale, 1.6 * scale, 0.9, "  OAL", "", "");
                fun.dimrot1(dxf, p15, p18, 0, d1 / 2.0, 0, 1.2 * scale, 1.6 * scale, 0.9, "  SDL_1", "", "");
                fun.dimrot1(dxf, p15, p14, -90, d1, 2, 1.2 * scale, 1.6 * scale, 0.9, "  DC_1", "", "");
                fun.dimrot1(dxf, p21, p20, -90, d1 * 2, 2, 1.2 * scale, 1.6 * scale, 0.9, "  DC_2", "", "");
                fun.dimrot1(dxf, fun.Polar(p14, 0, 0.001), p14, 180, d1 * 1.5, 2, 1.2 * scale, 1.6 * scale, 0.9, "  LF", "", "");
                fun.dimrot1(dxf, p13, p14, 180, d1, 2, 1.2 * scale, 1.6 * scale, 0.9, "  PL", "", "");
                fun.dimrot1(dxf, p21, p13, 0, d1, 2, 1.2 * scale, 1.6 * scale, 0.9, "  SD_2", "", "");
                fun.dimrot1(dxf, p23_1, p13, 0, d1 * 1.4, 2, 1.2 * scale, 1.6 * scale, 0.9, "  LU", "", "");
                fun.dimrot1(dxf, p24, p13, 0, d1 * 1.8, 2, 1.2 * scale, 1.6 * scale, 0.9, "  LCF", "", "");
                fun.jdbz2(dxf, new Line(p13, fun.Polar(p13, pi / -3, 0.1)), new Line(p13, fun.Polar(p13, pi / 3, 0.1)), d1 * 1.5, 1.2 * scale, 1.6 * scale, 0.9, "SIG", "", "");

                Vector2 p65 = fun.Polar(p13, pi / -2, d / 2.0 + (d1 / 2.0 - d / 2.0) / 2.0);
                Vector2 p66 = fun.Polar(p65, pi, 100);
                Arc arc8 = fun.DrawArc(p17, p36, p20);
                Vector2 p67 = fun.Inters1(p65, p66, arc8, 0);
                Vector2 p68 = fun.Polar(p67, -100 * pi / 180, 10);
                Vector2 p69 = fun.Polar(p68, -100 * pi / 180, 10);
                Vector2 p70 = fun.Polar(p68, pi / -2, 1.2 + 0.3);
                fun.Singlelinearrow(dxf, "RCSK", p67, -100, p68, p69, 1.2 * scale, 1.6);
            }
            else
            {

            }
            Vector2 p71 = fun.Polar(zxd, pi / 2, d1 / 2 + 3);
            Vector2 p72 = fun.Polar(p71, pi / 2 + pi / 4, 5);
            Vector2 p73 = fun.Polar(p72, pi, 5);
            Vector2 p74 = fun.mirrorpoint(p71, p1, p13);
            Vector2 p75 = fun.mirrorpoint(p72, p1, p13);
            Vector2 p76 = fun.mirrorpoint(p73, p1, p13);

            Line line2_1 = new Line(p73, p72);
            Line line2_2 = new Line(p72, p71);
            Line line2_3 = new Line(p71, p74);
            Line line2_4 = new Line(p74, p75);
            Line line2_5 = new Line(p75, p76);
            line2_1.Layer = additionalline;
            line2_1.Linetype = Linetype.Dashed;
            dxf.AddEntity(line2_1);

            line2_2.Layer = additionalline;
            line2_2.Linetype = Linetype.Dashed;
            dxf.AddEntity(line2_2);

            line2_3.Layer = additionalline;
            line2_3.Linetype = Linetype.Dashed;
            dxf.AddEntity(line2_3);

            line2_4.Layer = additionalline;
            line2_4.Linetype = Linetype.Dashed;
            dxf.AddEntity(line2_4);

            line2_5.Layer = additionalline;
            line2_5.Linetype = Linetype.Dashed;
            dxf.AddEntity(line2_5);


            double isframe = Convert.ToInt32(data["isframe"]);
            String isframe_chose = Convert.ToString(data["isframe_chose"]);
            Vector2 p0 = new Vector2(0, 0);
            if (isframe == 1)
            {
                if (isframe_chose.Equals("0"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA0X(dxf, new Vector2(p0.X - 1189 / 2.0, p0.Y + 841 / 2.0), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }

                if (isframe_chose.Equals("1"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA1X(dxf, new Vector2(p0.X - 841 / 2.0, p0.Y + 594 / 2.0), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }

                if (isframe_chose.Equals("2"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA2X(dxf, new Vector2(p0.X - 594 / 2.0, p0.Y + 420 / 2.0), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }

                if (isframe_chose.Equals("3"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA3X(dxf, new Vector2(p0.X - 420 / 2.0, p0.Y + 297 / 2.0), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }

                if (isframe_chose.Equals("4X"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA4X(dxf, new Vector2(p0.X - 297 / 2.0, p0.Y + 210 / 2.0 - 10 * 2.26), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }

                if (isframe_chose.Equals("4Y"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA4Y(dxf, new Vector2(p0.X - 210 / 2.0, p0.Y + 297 / 2.0), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }
            }

            /*
            fun.dimrot1(dxf, p0, fun.Polar(p7, 1.08752241, l * (0.86539032 / 12.0)), 0, d, 2, 1.2, 1.6, 0.9, "  l=" + l, "", "");
            fun.jdbz2(dxf, new Line(p17, fun.Polar(p17, 0, 0.1)), new Line(p17, fun.Polar(p17, γf * pi / 180, 0.1)), d1 / 2, 1.6, 0.5, 0.9, "γf=" + γf + "°", "", "");
            */

            fun.SetLayer(dxf);
            fun.SetByLayer(dxf);

            dxf.DrawingVariables.AcadVer = DxfVersion.AutoCad2007;
            dxf.Save(path);
        }

        public static void IntegralFried(Dictionary<string, Object> data)    //整体麻花钻
        {
            DxfDocument dxf = new DxfDocument();
            dxf.Layers["0"].Lineweight = Lineweight.W25;
            Layer contour = new Layer("contour");//轮廓层
            Layer dimensioning = new Layer("dimensioning");//尺寸层
            Layer refin = new Layer("refin");//基准线/内轮廓/虚线
            Layer center = new Layer("center");//中心线
            Layer textlayer = new Layer("textlayer");//文本层
            Layer hatching = new Layer("hatching");//填充层
            Layer additionalline = new Layer("additionalline");//附加线
            Layer cutting = new Layer("cutting");//切削层
            fun.SetLayer(dxf);

            //double sl_ = 80;
            //double scale = 1;

            //if (sl_ <= 67)
            //{
            //    scale = 5;
            //}
            //else if (67 < sl_ && sl_ <= 75)
            //{
            //    scale = 4;
            //}
            //else if (75 < sl_ && sl_ <= 100)
            //{
            //    scale = 3;
            //}
            //else
            //{
            //    scale = 6;
            //}
            //string path = Convert.ToString(data["path"]);
            //double pi = Math.PI;
            //double dc = 10 * scale;
            //double oal = 80 * scale;
            //double lcf = 44 * scale;
            //double sl = 35 * scale;
            //double lta = 54 * scale;
            //double dconms = 12 * scale;
            //double sig = 120;
            //double fha = 42;
            //double fha_ = fha * pi / 180;
            //double sig_ = sig * pi / 180;
           
            double sl_ = Convert.ToDouble(data["oal"]);
            double scale = Convert.ToDouble(data["scale"]);

            if (sl_ <= 67)
            {
                scale = 5;
            }
            else if (67 < sl_ && sl_ <= 75)
            {
                scale = 4;
            }
            else if (75 < sl_ && sl_ <= 100)
            {
                scale = 3;
            }
            else
            {
                scale = 6;
            }
            string path = Convert.ToString(data["path"]);
            double pi = Math.PI;
            double dc = Convert.ToDouble(data["dc"]) * scale;
            double oal = Convert.ToDouble(data["oal"]) * scale;
            double lcf = Convert.ToDouble(data["lcf"]) * scale;
            double ls = Convert.ToDouble(data["ls"]) * scale;
            double lta = Convert.ToDouble(data["lta"]) * scale;
            double dconms = Convert.ToDouble(data["dconms"]) * scale;
            double sig = Convert.ToDouble(data["sig"]);
            double fha = Convert.ToDouble(data["fha"]);
            double fha_ = fha * pi / 180;
            double sig_ = sig * pi / 180;


            var p0 = new Vector2(0, 0);
            var p0_1 = new Vector2(-5, 0);
            var p0_2 = new Vector2(oal + 5, 0);
            var p1 = fun.Polar(p0, sig_ / 2.0, (dc / 2.0) / (Math.Sin(sig_ / 2.0)));
            var p2 = fun.mirrorpoint(p1, p0_2, p0_1);
            var v2 = new Vector2(oal + 5, p2.Y);
            var v2_1 = fun.Polar(p2, pi / -2, 0.00001);
            var v2_2 = new Vector2(v2_1.X + oal + 5, v2_1.Y);
            var v0 = fun.Polar(p0, 0, (dc / 2.0) / (Math.Tan(sig_ / 2.0)));
            var p3 = fun.Polar(v0, pi / 2, dc / 10);
            var v3 = fun.Polar(p3, -fha_, oal);
            var p4_ = fun.Inters(p3, v3, p2, v2);
            var p4 = fun.Polar(p4_, pi / 2, 0.00001);
            var v5 = fun.Polar(p2, 7 * pi / 180, 100);
            Line line1 = new Line(v2_1, v2_2);
            Arc arc1 = fun.DrawArc5(p3, line1, p4);
            var p5 = fun.Inters1(p2, v5, arc1, 0);//逆时针，0靠近的那个点
            var v3_1 = new Vector2(-oal, p3.Y);
            Line line2 = new Line(v3_1, p3);
            var v1_1 = new Vector2(p1.X, p1.Y + 0.00001);
            var v1_2 = new Vector2(v1_1.X + oal + 5, v1_1.Y);

            Line line3 = new Line(v1_1, v1_2);
            var p6 = fun.Polar(p0, 0, p3.X + lcf * (40.22 / 3.0) / 44);
            Arc arc4 = fun.DrawArc5(p6, line3, p1);
            var p7 = fun.PointRotate(p6, p1, pi);
            Arc arc5 = fun.DrawArc5(p6, line1, p7);
            var p8 = fun.Polar(p6, pi, 1.1 / 44 * lcf);
            Arc arc6 = fun.DrawArc5(p8, line3, p1);
            Arc arc7 = fun.DrawArc5(p8, line1, p7);
            var v9_1 = fun.Polar(p1, pi / -2, fun.CalDistance(p1, p3) / 3.0);
            var v9_2 = fun.Polar(v9_1, 0, oal + 5);
            var p9 = fun.Inters1(v9_1, v9_2, arc4, 1);
            var p10 = fun.Polar(p6, 0, 34.22 / 3.0 / 44 * lcf);
            Arc arc8 = fun.DrawArc5(p10, line3, p9);
            var v13 = fun.Polar(fun.Polar(p1, pi / -2, 0.01), 0, oal + 5);
            var p13 = fun.Inters1(fun.Polar(p1, pi / -2, 0.01), v13, arc8, 1);
            var p11 = fun.PointRotate(p10, p13, pi);
            Arc arc9 = fun.DrawArc5(p10, line1, p11);
            var v12 = fun.Polar(p7, 7 * pi / 180, 100);
            var p12 = fun.Inters1(p7, v12, arc9, 0);
            Arc arc10 = fun.DrawArc5(p7, line1, p12);
            var p14 = fun.Polar(p10, 0, lcf * (40.22 / 3.0) / 44);
            var p15 = fun.Polar(p14, pi, 1.1 / 44 * lcf);
            var p16 = fun.Inters(p10, fun.Polar(p10, pi / 2, oal), p13, fun.Polar(p13, 0, oal));
            Arc arc11 = fun.DrawArc5(p14, line3, p16);
            Arc arc12 = fun.DrawArc5(p15, line3, p16);
            var p17 = fun.Inters(p2, fun.Polar(p2, 0, oal + 5), p14, fun.Polar(p14, pi / -2, oal + 5));
            var p18 = fun.Inters(p17, fun.Polar(p17, pi / 2, oal + 5), p15, fun.Polar(p15, -fha_, oal + 5));
            Arc arc13 = fun.DrawArc4(p17, 2.82 / 16.28 * arc12.Radius, p18, 0);
            var p19 = fun.Inters1(v9_1, v9_2, arc11, 1);
            var p20 = fun.Polar(p2, 0, lcf);
            var p21 = fun.Inters(p19, fun.Polar(p19, 9 * pi / 180, oal + 5), p1, fun.Polar(p1, 0, oal + 5));
            Arc arc14 = fun.DrawArc5(p21, line3, p19);
            var p22 = fun.Inters(p14, fun.Polar(p14, fha_, oal + 5), p21, fun.Polar(p21, -fha_, oal + 5));
            var v18_ = new Vector2(p18.X + oal + 5, p18.Y);
            var p24 = fun.Polar(p20, -pi / 4, Math.Sqrt(2) * (oal - lcf - ls ));
            var p25 = fun.Polar(p24, pi / 2, dconms);
            var p26 = fun.Polar(p25, 0, ls - 1);
            var p27 = fun.Polar(p26, pi / -2, dconms);
            var p28 = fun.Polar(p27, pi / 4, Math.Sqrt(2) * (1));
            var p29 = fun.Polar(p26, pi / -4, Math.Sqrt(2) * (1));
            var v21_1 = fun.Polar(p21, pi / -2, 0.001);
            var v21_2 = new Vector2(v21_1.X + oal + 5, v21_1.Y);
            Line line11 = new Line(v21_1, v21_2);
            Arc arc16 = fun.DrawArc5(p21, line11, p25);
            Line line10 = new Line(p18, v18_);
            Arc arc15 = fun.DrawArc5(p14, line10, p22);
            // Line linesy = new Line(p13, p0);          
            Line line4 = new Line(p4, p7);
            Line line5 = new Line(p13, p16);
            Line line6 = new Line(p11, p17);
            Line line7 = new Line(p15, p18);
            Line line8 = new Line(p17, p20);
            Line line9 = new Line(p21, p22);
            Arc arc3 = fun.DrawArc5(fun.Polar(p3, pi / -2, 0.00001), line2, p0);
            Arc arc2 = fun.DrawArc5(fun.Polar(p2, pi / 2, 0.00001), line1, p5);
            var polyline1 = Pus.AddPointsToLwPolyLine(p3, p1, p0, p2);
            var polyline2 = Pus.AddPointsToLwPolyLine(p25, p24, p20, p24, p27, p28, p29, p26, p27, p26, p25);
            fun.drawBline(dxf, line4, 0.5, contour);
            fun.drawBline(dxf, line5, 0.5, contour);
            fun.drawBline(dxf, line6, 0.5, contour);
            fun.drawBline(dxf, line7, 0.5, contour);
            fun.drawBline(dxf, line8, 0.5, contour);
            fun.drawBline(dxf, line9, 0.5, contour);
            fun.drawBArc(dxf, arc1, 0.5, contour);
            fun.drawBArc(dxf, arc2, 0.5, contour);
            fun.drawBArc(dxf, arc3, 0.5, contour);
            fun.drawBArc(dxf, arc4, 0.5, contour);
            fun.drawBArc(dxf, arc5, 0.5, contour);
            fun.drawBArc(dxf, arc6, 0.5, contour);
            fun.drawBArc(dxf, arc7, 0.5, contour);
            fun.drawBArc(dxf, arc8, 0.5, contour);
            fun.drawBArc(dxf, arc9, 0.5, contour);
            fun.drawBArc(dxf, arc10, 0.5, contour);
            fun.drawBArc(dxf, arc11, 0.5, contour);
            fun.drawBArc(dxf, arc12, 0.5, contour);
            fun.drawBArc(dxf, arc13, 0.5, contour);
            fun.drawBArc(dxf, arc14, 0.5, contour);
            fun.drawBArc(dxf, arc15, 0.5, contour);
            fun.drawBArc(dxf, arc16, 0.5, contour);
            fun.PolyFill(dxf, polyline1, 0.5, contour);
            fun.PolyFill(dxf, polyline2, 0.5, contour);
            //标注
            var v100 = fun.Polar(p2, 0, lta);
            var v101 = fun.Polar(p29, pi / 3.0, dc * 1.5);
            var v102 = fun.Polar(p28, pi / 2, fun.CalDistance(p29, p28) / 2.0);
            var v103 = fun.Polar(p0, 0, p3.X + lta);
            var v104 = fun.Polar(v103, pi / -4, oal);
            var v105 = fun.Inters(p24, p27, v103, v104);
            var v106 = fun.Polar(v105, pi / -4, dc / 2.0);
            var v107 = fun.Polar(v106, pi / -4, dc / 2.0);
            var v108 = fun.Polar(p2, pi + pi / 3, dc * 1.5);
            var v109 = fun.Polar(v108, pi, dc / 2.0);
            var v110 = fun.Polar(v109, pi, dc / 2.0);
            //
            var v111 = fun.Polar(v103, pi / 2, dconms / 2.0 + 3);
            var v112 = fun.Polar(v111, pi / 4, dconms / 10);
            var v113 = fun.Polar(v112, 0, dconms / 4.0);

            var v115 = fun.mirrorpoint(v111, p0_2, p0_1);
            var v116 = fun.mirrorpoint(v112, p0_1, p0_2);
            var v117 = fun.mirrorpoint(v113, p0_1, p0_2);
            //
            var v118 = fun.Polar(p1, pi / 4, 1.7);
            var v119 = fun.Polar(v118, pi / 4, dc / 2.0);
            var v120 = fun.Polar(v102, pi / 4, 1.7 * 0.5);
            var v121 = fun.Polar(v120, pi / 4, dc);
            var v122 = fun.Polar(v103, pi / 4, 1.7 * 0.5);
            var v123 = fun.Polar(v122, pi / 4, dc);
            var v124 = fun.Polar(p0, pi / 2 + 25 * pi / 180, 1.7 * 0.5);
            var v125 = fun.Polar(v124, pi / 2 + 25 * pi / 180, dc);

            fun.dimrot1(dxf, p0, fun.Polar(p11, 0, fun.CalDistance(p11, p17) / 2.0), 180, dc, 2, 1.2 * scale, 1.6 * scale, 0.9, "LU", " ", " ");
            fun.dimrot1(dxf, p0, p20, 180, dc * 1.5, 2, 1.2 * scale, 1.6 * scale, 0.9, "LCF="+lcf/scale , " ", " ");
            fun.dimrot1(dxf, p2, v100, 180, dc * 2.2 - dc / 2.0, 2, 1.2 * scale, 1.6 * scale, 0.9, "LTA="+lta/scale , " ", " ");
            fun.dimrot1(dxf, p0, v100, 180, dc * 3.4 - dc, 2, 1.2 * scale, 1.6 * scale, 0.9, "LPR", " ", " ");
            fun.dimrot1(dxf, p0, p29, 180, dc * 4.6 - dc, 2, 1.2 * scale, 1.6 * scale, 0.9, "OAL="+oal/scale , " ", " ");
            fun.dimrot1(dxf, p1, p2, 90, dc, 2, 1.2 * scale, 1.6 * scale, 0.9, "DC="+dc/scale , " ", " ");
            fun.dimrot1(dxf, p26, p27, -90, dc, 2, 1.2 * scale, 1.6 * scale, 0.9, "DCONMS="+dconms/scale , " ", " ");
            fun.dimrot1(dxf, p25, p29, 0, dc, 2, 1.2 * scale, 1.6 * scale, 0.9, "LS="+ls/scale , " ", " ");
            fun.dimrot1(dxf, fun.Polar(p29, pi / 2, 1), p1, 0, dc * 1.5, 2, 1.2 * scale, 1.6 * scale, 0.9, "LF", " ", " ");
            fun.dimrot1(dxf, p0, p1, 0, dc * 1.5 + dc / 3.3333, 2, 1.2 * scale, 1.6 * scale, 0.9, "PL", " ", " ");

            fun.jdbz2(dxf, new Line(p0, fun.Polar(p0, pi - sig_ / 2.0, 0.0001)), new Line(p0, fun.Polar(p0, pi + sig_ / 2.0, 0.001)), dc * 1.5, 1.2 * scale, 1.6 * scale, 0.9, "SIG" , "", "");
            fun.jdbz2(dxf, new Line(p19, fun.Polar(p19, pi - fha_, 0.001)), new Line(p16, p13), dc * 2, 1.2 * scale, 1.6 * scale, 0.9, "FHA" , "", "");
            fun.Axis(dxf, v101, 90, 0, "X", "Z", "Y", 0.5 * scale, 1.2 * scale, 1.6 * scale);
            fun.Axis(dxf, v102, 90, 0, "", "", "", 0.5 * scale, 1.2 * scale, 1.6 * scale);
            fun.Axis(dxf, p0, 90, 0, "", "", "", 0.5 * scale, 1.2 * scale, 1.6 * scale);
            fun.Axis(dxf, v103, 90, 0, "", "", "", 0.5 * scale, 1.2 * scale, 1.6 * scale);

            fun.Singlelinearrow(dxf, "CCMS", v105, -45, v106, v107, 1.2 * scale, 1.6 * scale);
            fun.Singlelinearrow(dxf, "FDP", v110, 180, v109, v108, 1.2 * scale, 1.6 * scale);

            Line linev1 = new Line(v111, v115);
            linev1.Lineweight = Lineweight.W25;//Lineweight指线宽
            linev1.Layer = additionalline;//Layer指图层
            //linev1.LinetypeScale = 5;//指线性比例
            //linev1.Linetype = Linetype.ByLayer;//Linetype指是点划线还是虚线什么的
            dxf.AddEntity(linev1); //提取

            Line linev2 = new Line(v111, v112);
            linev2.Lineweight = Lineweight.W25;//Lineweight指线宽
            linev2.Layer = additionalline;//Layer指图层
            //linev2.LinetypeScale = 5;//指线性比例
            //linev2.Linetype = Linetype.ByLayer;//Linetype指是点划线还是虚线什么的
            dxf.AddEntity(linev2); //提取

            Line linev3 = new Line(v112, v113);
            linev3.Lineweight = Lineweight.W25;//Lineweight指线宽
            linev3.Layer = additionalline;//Layer指图层
            //linev3.LinetypeScale = 5;//指线性比例
            //linev3.Linetype = Linetype.ByLayer;//Linetype指是点划线还是虚线什么的
            dxf.AddEntity(linev3); //提取

            Line linev4 = new Line(v115, v116);
            linev4.Lineweight = Lineweight.W25;//Lineweight指线宽
            linev4.Layer = additionalline;//Layer指图层
            //linev4.LinetypeScale = 5;//指线性比例
            //linev4.Linetype = Linetype.ByLayer;//Linetype指是点划线还是虚线什么的
            dxf.AddEntity(linev4); //提取

            Line linev5 = new Line(v116, v117);
            linev5.Lineweight = Lineweight.W25;//Lineweight指线宽
            linev5.Layer = additionalline;//Layer指图层
            //linev5.LinetypeScale = 5;//指线性比例
            //linev5.Linetype = Linetype.ByLayer;//Linetype指是点划线还是虚线什么的
            dxf.AddEntity(linev5); //提取

            Line linev7 = new Line(p0_1, p0_2);
            linev7.Lineweight = Lineweight.W25;//Lineweight指线宽
            linev7.Layer = center;//Layer指图层
            //linev7.LinetypeScale = 5;//指线性比例
            //linev7.Linetype = Linetype.ByLayer;//Linetype指是点划线还是虚线什么的
            dxf.AddEntity(linev7); //提取

            Line linev6 = new Line(v118, v119);
            Line linev8 = new Line(v120, v121);
            Line linev9 = new Line(v122, v123);
            Line linev10 = new Line(v124, v125);
            Circle circle1 = new Circle(p1, 1.7 * 0.5 * scale);
            Text txt1 = new Text("CRP", v119, 1.2 * scale, 0);
            Text txt2 = new Text("PCS", v121, 1.2 * scale, 0);
            Text txt3 = new Text("MCS", v123, 1.2 * scale, 0);
            Text txt4 = new Text("CIP", v125, 1.2 * scale, 0);
            dxf.AddEntity(new EntityObject[] { circle1, linev6, linev8, linev9, linev10, txt1, txt2, txt3, txt4 });


            double isframe = Convert.ToInt32(data["isframe"]);
            String isframe_chose = Convert.ToString(data["isframe_chose"]);
            if (isframe == 1)
            {
                if (isframe_chose.Equals("0"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA0X(dxf, new Vector2(p0.X - 1189 / 2.0, p0.Y + 841 / 2.0), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }

                if (isframe_chose.Equals("1"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA1X(dxf, new Vector2(p0.X - 841 / 2.0, p0.Y + 594 / 2.0), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }

                if (isframe_chose.Equals("2"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA2X(dxf, new Vector2(p0.X - 594 / 2.0, p0.Y + 420 / 2.0), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }

                if (isframe_chose.Equals("3"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA3X(dxf, new Vector2(p0.X - 420 / 2.0, p0.Y + 297 / 2.0), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }

                if (isframe_chose.Equals("4X"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA4X(dxf, new Vector2(p0.X - 297 / 2.0, p0.Y + 210 / 2.0 - 10 * 2.26), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }

                if (isframe_chose.Equals("4Y"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA4Y(dxf, new Vector2(p0.X - 210 / 2.0, p0.Y + 297 / 2.0), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }
            }
            fun.SetLayer(dxf);
            fun.SetByLayer(dxf);
            


            dxf.DrawingVariables.AcadVer = DxfVersion.AutoCad2007;
            dxf.Save(path);
        }
        public static void ISYC_302_01(Dictionary<string, Object> data)    //整体麻花钻
        {
            DxfDocument dxf = new DxfDocument();
            dxf.Layers["0"].Lineweight = Lineweight.W25;
            Layer contour = new Layer("contour");//轮廓层
            Layer dimensioning = new Layer("dimensioning");//尺寸层
            Layer refin = new Layer("refin");//基准线/内轮廓/虚线
            Layer center = new Layer("center");//中心线
            Layer textlayer = new Layer("textlayer");//文本层
            Layer hatching = new Layer("hatching");//填充层
            Layer additionalline = new Layer("additionalline");//附加线
            Layer cutting = new Layer("cutting");//切削层
            fun.SetLayer(dxf);

            /*
            double sl_ = 80;
            double scale = 1;

            if (sl_ <= 67)
            {
                scale = 5;
            }
            else if (67 < sl_ && sl_ <= 75)
            {
                scale = 4;
            }
            else if (75 < sl_ && sl_ <= 100)
            {
                scale = 3;
            }
            else
            {
                scale = 6;
            }

            string path = Convert.ToString(data["path"]);
            double pi = Math.PI;
            double dc = 10 * scale;
            double oal = 80 * scale;
            double lcf = 44 * scale;
            double sl = 35 * scale;
            double lta = 54 * scale;
            double dconms = 12 * scale;
            double sig = 120;
            double fha = 42;
            double fha_ = fha * pi / 180;
            double sig_ = sig * pi / 180;
            */
            double sl_ = Convert.ToDouble(data["oal"]);
            double scale = Convert.ToDouble(data["scale"]);

            if (sl_ <= 67)
            {
                scale = 5;
            }
            else if (67 < sl_ && sl_ <= 75)
            {
                scale = 4;
            }
            else if (75 < sl_ && sl_ <= 100)
            {
                scale = 3;
            }
            else
            {
                scale = 6;
            }
            string path = Convert.ToString(data["path"]);
            double pi = Math.PI;
            double dc = Convert.ToDouble(data["dc"]) * scale;
            double oal = Convert.ToDouble(data["oal"]) * scale;
            double lcf = Convert.ToDouble(data["lcf"]) * scale;
            double sl = Convert.ToDouble(data["sl"]) * scale;
            double lta = Convert.ToDouble(data["lta"]) * scale;
            double dconms = Convert.ToDouble(data["dconms"]) * scale;
            double sig = Convert.ToDouble(data["sig"]);
            double fha = Convert.ToDouble(data["fha"]);
            double fha_ = fha * pi / 180;
            double sig_ = sig * pi / 180;
            var p0 = new Vector2(0, 0);
            var p0_1 = new Vector2(-5, 0);
            var p0_2 = new Vector2(oal + 5, 0);
            var p1 = fun.Polar(p0, sig_ / 2.0, (dc / 2.0) / (Math.Sin(sig_ / 2.0)));
            var p2 = fun.mirrorpoint(p1, p0_2, p0_1);
            var v2 = new Vector2(oal + 5, p2.Y);
            var v2_1 = fun.Polar(p2, pi / -2, 0.00001);
            var v2_2 = new Vector2(v2_1.X + oal + 5, v2_1.Y);
            var v0 = fun.Polar(p0, 0, (dc / 2.0) / (Math.Tan(sig_ / 2.0)));
            var p3 = fun.Polar(v0, pi / 2, dc / 10);
            var v3 = fun.Polar(p3, -fha_, oal);
            var p4_ = fun.Inters(p3, v3, p2, v2);
            var p4 = fun.Polar(p4_, pi / 2, 0.00001);
            var v5 = fun.Polar(p2, 7 * pi / 180, 100);
            Line line1 = new Line(v2_1, v2_2);
            Arc arc1 = fun.DrawArc5(p3, line1, p4);
            var p5 = fun.Inters1(p2, v5, arc1, 0);//逆时针，0靠近的那个点
            var v3_1 = new Vector2(-oal, p3.Y);
            Line line2 = new Line(v3_1, p3);
            var v1_1 = new Vector2(p1.X, p1.Y + 0.00001);
            var v1_2 = new Vector2(v1_1.X + oal + 5, v1_1.Y);

            Line line3 = new Line(v1_1, v1_2);
            var p6 = fun.Polar(p0, 0, p3.X + lcf * (40.22 / 3.0) / 44);
            Arc arc4 = fun.DrawArc5(p6, line3, p1);
            var p7 = fun.PointRotate(p6, p1, pi);
            Arc arc5 = fun.DrawArc5(p6, line1, p7);
            var p8 = fun.Polar(p6, pi, 1.1 / 44 * lcf);
            Arc arc6 = fun.DrawArc5(p8, line3, p1);
            Arc arc7 = fun.DrawArc5(p8, line1, p7);
            var v9_1 = fun.Polar(p1, pi / -2, fun.CalDistance(p1, p3) / 3.0);
            var v9_2 = fun.Polar(v9_1, 0, oal + 5);
            var p9 = fun.Inters1(v9_1, v9_2, arc4, 1);
            var p10 = fun.Polar(p6, 0, 34.22 / 3.0 / 44 * lcf);
            Arc arc8 = fun.DrawArc5(p10, line3, p9);
            var v13 = fun.Polar(fun.Polar(p1, pi / -2, 0.01), 0, oal + 5);
            var p13 = fun.Inters1(fun.Polar(p1, pi / -2, 0.01), v13, arc8, 1);
            var p11 = fun.PointRotate(p10, p13, pi);
            Arc arc9 = fun.DrawArc5(p10, line1, p11);
            var v12 = fun.Polar(p7, 7 * pi / 180, 100);
            var p12 = fun.Inters1(p7, v12, arc9, 0);
            Arc arc10 = fun.DrawArc5(p7, line1, p12);
            var p14 = fun.Polar(p10, 0, lcf * (40.22 / 3.0) / 44);
            var p15 = fun.Polar(p14, pi, 1.1 / 44 * lcf);
            var p16 = fun.Inters(p10, fun.Polar(p10, pi / 2, oal), p13, fun.Polar(p13, 0, oal));
            Arc arc11 = fun.DrawArc5(p14, line3, p16);
            Arc arc12 = fun.DrawArc5(p15, line3, p16);
            var p17 = fun.Inters(p2, fun.Polar(p2, 0, oal + 5), p14, fun.Polar(p14, pi / -2, oal + 5));
            var p18 = fun.Inters(p17, fun.Polar(p17, pi / 2, oal + 5), p15, fun.Polar(p15, -fha_, oal + 5));
            Arc arc13 = fun.DrawArc4(p17, 2.82 / 16.28 * arc12.Radius, p18, 0);
            var p19 = fun.Inters1(v9_1, v9_2, arc11, 1);
            var p20 = fun.Polar(p2, 0, lcf);
            var p21 = fun.Inters(p19, fun.Polar(p19, 9 * pi / 180, oal + 5), p1, fun.Polar(p1, 0, oal + 5));
            Arc arc14 = fun.DrawArc5(p21, line3, p19);
            var p22 = fun.Inters(p14, fun.Polar(p14, fha_, oal + 5), p21, fun.Polar(p21, -fha_, oal + 5));
            var v18_ = new Vector2(p18.X + oal + 5, p18.Y);
            var p24 = fun.Polar(p20, -pi / 4, Math.Sqrt(2) * (oal - lcf - sl));
            var p25 = fun.Polar(p24, pi / 2, dconms);
            var p26 = fun.Polar(p25, 0, sl - 1);
            var p27 = fun.Polar(p26, pi / -2, dconms);
            var p28 = fun.Polar(p27, pi / 4, Math.Sqrt(2) * (1));
            var p29 = fun.Polar(p26, pi / -4, Math.Sqrt(2) * (1));
            var v21_1 = fun.Polar(p21, pi / -2, 0.001);
            var v21_2 = new Vector2(v21_1.X + oal + 5, v21_1.Y);
            Line line11 = new Line(v21_1, v21_2);
            Arc arc16 = fun.DrawArc5(p21, line11, p25);
            Line line10 = new Line(p18, v18_);
            Arc arc15 = fun.DrawArc5(p14, line10, p22);
            // Line linesy = new Line(p13, p0);          
            Line line4 = new Line(p4, p7);
            Line line5 = new Line(p13, p16);
            Line line6 = new Line(p11, p17);
            Line line7 = new Line(p15, p18);
            Line line8 = new Line(p17, p20);
            Line line9 = new Line(p21, p22);
            Arc arc3 = fun.DrawArc5(fun.Polar(p3, pi / -2, 0.00001), line2, p0);
            Arc arc2 = fun.DrawArc5(fun.Polar(p2, pi / 2, 0.00001), line1, p5);
            var polyline1 = Pus.AddPointsToLwPolyLine(p3, p1, p0, p2);
            var polyline2 = Pus.AddPointsToLwPolyLine(p25, p24, p20, p24, p27, p28, p29, p26, p27, p26, p25);
            fun.drawBline(dxf, line4, 0.5, contour);
            fun.drawBline(dxf, line5, 0.5, contour);
            fun.drawBline(dxf, line6, 0.5, contour);
            fun.drawBline(dxf, line7, 0.5, contour);
            fun.drawBline(dxf, line8, 0.5, contour);
            fun.drawBline(dxf, line9, 0.5, contour);
            fun.drawBArc(dxf, arc1, 0.5, contour);
            fun.drawBArc(dxf, arc2, 0.5, contour);
            fun.drawBArc(dxf, arc3, 0.5, contour);
            fun.drawBArc(dxf, arc4, 0.5, contour);
            fun.drawBArc(dxf, arc5, 0.5, contour);
            fun.drawBArc(dxf, arc6, 0.5, contour);
            fun.drawBArc(dxf, arc7, 0.5, contour);
            fun.drawBArc(dxf, arc8, 0.5, contour);
            fun.drawBArc(dxf, arc9, 0.5, contour);
            fun.drawBArc(dxf, arc10, 0.5, contour);
            fun.drawBArc(dxf, arc11, 0.5, contour);
            fun.drawBArc(dxf, arc12, 0.5, contour);
            fun.drawBArc(dxf, arc13, 0.5, contour);
            fun.drawBArc(dxf, arc14, 0.5, contour);
            fun.drawBArc(dxf, arc15, 0.5, contour);
            fun.drawBArc(dxf, arc16, 0.5, contour);
            fun.PolyFill(dxf, polyline1, 0.5, contour);
            fun.PolyFill(dxf, polyline2, 0.5, contour);
            //标注
            var v100 = fun.Polar(p2, 0, lta);
            var v101 = fun.Polar(p29, pi / 3.0, dc * 1.5);
            var v102 = fun.Polar(p28, pi / 2, fun.CalDistance(p29, p28) / 2.0);
            var v103 = fun.Polar(p0, 0, p3.X + lta);
            var v104 = fun.Polar(v103, pi / -4, oal);
            var v105 = fun.Inters(p24, p27, v103, v104);
            var v106 = fun.Polar(v105, pi / -4, dc / 2.0);
            var v107 = fun.Polar(v106, pi / -4, dc / 2.0);
            var v108 = fun.Polar(p2, pi + pi / 3, dc * 1.5);
            var v109 = fun.Polar(v108, pi, dc / 2.0);
            var v110 = fun.Polar(v109, pi, dc / 2.0);
            //
            var v111 = fun.Polar(v103, pi / 2, dconms / 2.0 + 3);
            var v112 = fun.Polar(v111, pi / 4, dconms / 10);
            var v113 = fun.Polar(v112, 0, dconms / 4.0);

            var v115 = fun.mirrorpoint(v111, p0_2, p0_1);
            var v116 = fun.mirrorpoint(v112, p0_1, p0_2);
            var v117 = fun.mirrorpoint(v113, p0_1, p0_2);
            //
            var v118 = fun.Polar(p1, pi / 4, 1.7);
            var v119 = fun.Polar(v118, pi / 4, dc / 2.0);
            var v120 = fun.Polar(v102, pi / 4, 1.7 * 0.5);
            var v121 = fun.Polar(v120, pi / 4, dc);
            var v122 = fun.Polar(v103, pi / 4, 1.7 * 0.5);
            var v123 = fun.Polar(v122, pi / 4, dc);
            var v124 = fun.Polar(p0, pi / 2 + 25 * pi / 180, 1.7 * 0.5);
            var v125 = fun.Polar(v124, pi / 2 + 25 * pi / 180, dc);

            var v126 = fun.Polar(p1, pi / 2, dc / 2.0);
            var v127 = fun.Polar(v126, 0, dc / 2.0);
            var v128 = fun.Polar(v127, 0, dc / 2.0);
            fun.dimrot1(dxf, p0, fun.Polar(p11, 0, fun.CalDistance(p11, p17) / 2.0), 180, dc, 2, 1.2 * scale, 1.6 * scale, 0.9, "LU", " ", " ");
            fun.dimrot1(dxf, p0, p20, 180, dc * 1.5, 2, 1.2 * scale, 1.6 * scale, 0.9, "LCF", " ", " ");
            fun.dimrot1(dxf, p0, v100, 180, dc * 3.4 - dc, 2, 1.2 * scale, 1.6 * scale, 0.9, "LPR", " ", " ");
            fun.dimrot1(dxf, p0, p29, 180, dc * 4.6 - dc, 2, 1.2 * scale, 1.6 * scale, 0.9, "OAL", " ", " ");
            fun.dimrot1(dxf, p1, p2, 90, dc, 2, 1.2 * scale, 1.6 * scale, 0.9, "DC", " ", " ");
            fun.dimrot1(dxf, p26, p27, -90, dc, 2, 1.2 * scale, 1.6 * scale, 0.9, "DMM", " ", " ");
            fun.dimrot1(dxf, p25, p29, 0, dc, 2, 1.2 * scale, 1.6 * scale, 0.9, "LS", " ", " ");
            fun.dimrot1(dxf, p0, p1, 0, dc * 1.5 + dc / 3.3333, 2, 1.2 * scale, 1.6 * scale, 0.9, "PL", " ", " ");

            fun.jdbz2(dxf, new Line(p0, fun.Polar(p0, pi - sig_ / 2.0, 0.0001)), new Line(p0, fun.Polar(p0, pi + sig_ / 2.0, 0.001)), dc * 1.5, 1.2 * scale, 1.6 * scale, 0.9, "SIG", "", "");
            fun.Singlelinearrow(dxf, "LF", v126, 180, v127, v128, 1.2 * scale, 1.6 * scale);

            Line linev1 = new Line(v111, v115);
            linev1.Lineweight = Lineweight.W35;//Lineweight指线宽
            linev1.Layer = additionalline;//Layer指图层
            linev1.LinetypeScale = 5;//指线性比例
            linev1.Linetype = Linetype.DashDot;//Linetype指是点划线还是虚线什么的
            dxf.AddEntity(linev1); //提取

            Line linev2 = new Line(v111, v112);
            linev2.Lineweight = Lineweight.W35;//Lineweight指线宽
            linev2.Layer = additionalline;//Layer指图层
            linev2.LinetypeScale = 5;//指线性比例
            linev2.Linetype = Linetype.DashDot;//Linetype指是点划线还是虚线什么的
            dxf.AddEntity(linev2); //提取

            Line linev3 = new Line(v112, v113);
            linev3.Lineweight = Lineweight.W35;//Lineweight指线宽
            linev3.Layer = additionalline;//Layer指图层
            linev3.LinetypeScale = 5;//指线性比例
            linev3.Linetype = Linetype.DashDot;//Linetype指是点划线还是虚线什么的
            dxf.AddEntity(linev3); //提取

            Line linev4 = new Line(v115, v116);
            linev4.Lineweight = Lineweight.W35;//Lineweight指线宽
            linev4.Layer = additionalline;//Layer指图层
            linev4.LinetypeScale = 5;//指线性比例
            linev4.Linetype = Linetype.DashDot;//Linetype指是点划线还是虚线什么的
            dxf.AddEntity(linev4); //提取

            Line linev5 = new Line(v116, v117);
            linev5.Lineweight = Lineweight.W35;//Lineweight指线宽
            linev5.Layer = additionalline;//Layer指图层
            linev5.LinetypeScale = 5;//指线性比例
            linev5.Linetype = Linetype.DashDot;//Linetype指是点划线还是虚线什么的
            dxf.AddEntity(linev5); //提取

            Line linev7 = new Line(p0_1, p0_2);
            linev7.Lineweight = Lineweight.W25;//Lineweight指线宽
            linev7.Layer = additionalline;//Layer指图层
            linev7.LinetypeScale = 5;//指线性比例
            linev7.Linetype = Linetype.DashDot;//Linetype指是点划线还是虚线什么的
            dxf.AddEntity(linev7); //提取

            double isframe = Convert.ToInt32(data["isframe"]);
            String isframe_chose = Convert.ToString(data["isframe_chose"]);
            if (isframe == 1)
            {
                if (isframe_chose.Equals("0"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA0X(dxf, new Vector2(p0.X - 1189 / 2.0, p0.Y + 841 / 2.0), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }

                if (isframe_chose.Equals("1"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA1X(dxf, new Vector2(p0.X - 841 / 2.0, p0.Y + 594 / 2.0), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }

                if (isframe_chose.Equals("2"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA2X(dxf, new Vector2(p0.X - 594 / 2.0, p0.Y + 420 / 2.0), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }

                if (isframe_chose.Equals("3"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA3X(dxf, new Vector2(p0.X - 420 / 2.0, p0.Y + 297 / 2.0), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }

                if (isframe_chose.Equals("4X"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA4X(dxf, new Vector2(p0.X - 297 / 2.0, p0.Y + 210 / 2.0 - 10 * 2.26), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }

                if (isframe_chose.Equals("4Y"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA4Y(dxf, new Vector2(p0.X - 210 / 2.0, p0.Y + 297 / 2.0), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }
            }


            fun.SetLayer(dxf);
            fun.SetByLayer(dxf);

            dxf.DrawingVariables.AcadVer = DxfVersion.AutoCad2007;
            dxf.Save(path);
        }
        public static void Straightshanktwistdrill(Dictionary<string, Object> data)    //整体硬质合金直柄麻花钻
        {
            DxfDocument dxf = new DxfDocument();
            dxf.Layers["0"].Lineweight = Lineweight.W25;
            Layer contour = new Layer("contour");//轮廓层
            Layer dimensioning = new Layer("dimensioning");//尺寸层
            Layer refin = new Layer("refin");//基准线/内轮廓/虚线
            Layer center = new Layer("center");//中心线
            Layer textlayer = new Layer("textlayer");//文本层
            Layer hatching = new Layer("hatching");//填充层
            Layer additionalline = new Layer("additionalline");//附加线
            Layer cutting = new Layer("cutting");//切削层
            fun.SetLayer(dxf);

            /*
            string path = Convert.ToString(data["path"]);
            double pi = Math.PI;
            double d1 = 3.0;
            double d2 = 6;
            double l1 = 62;
            double l2 = 20;
            double l3 = 14;
            double h2 = 5.1;
            double l4 = 36;
            double l5 = 25;
            double l6 = 18;
            double r2 = 1.2;
            double eper = 140;
            double eper_ = eper * pi / 180;
            double l3bl = 53.26513089;
            double l2bl = 58.36993834;
            */
            //d = Convert.ToDouble(data["dc1"]);
            double scale = Convert.ToDouble(data["scale"]); //放大系数
            string path = Convert.ToString(data["path"]);
            double pi = Math.PI;
            double d1 = Convert.ToDouble(data["dc"])* scale;
            double d2 = Convert.ToDouble(data["dcon"])* scale;
            double l1 = Convert.ToDouble(data["oal"])* scale;
            double l2 = Convert.ToDouble(data["lcf"])* scale;
            double l3 = Convert.ToDouble(data["lu"])* scale;
            double h2 = Convert.ToDouble(data["h2"])* scale;
            double l4 = Convert.ToDouble(data["ls"])* scale;
            double l5 = Convert.ToDouble(data["lsc"])* scale;
            double l6 = Convert.ToDouble(data["l6"]);
            double r2 = Convert.ToDouble(data["r2"]);
            double eper = Convert.ToDouble(data["eper"]);
            double eper_ = eper * pi / 180;
            double l3bl = 53.26513089;
            double l2bl = 58.36993834;
            Vector2 zx1 = new Vector2(-5, 0);
            Vector2 zx2 = fun.Polar(zx1, 0, l1 + 10);
            Vector2 p0 = new Vector2(l1 - l4 - (((d2 - d1) / 2)), 0);
            Vector2 p20 = new Vector2(0, 0);
            Vector2 p16 = fun.Polar(p20, eper_ / 2, (d1 / 2) / Math.Sin(eper_ / 2));
            Vector2 p23 = fun.mirrorpoint(p16, zx1, zx2);
            Vector2 p17 = fun.Polar(p20, eper_ / 2, (d1 / 2 / Math.Sin(eper_ / 2)) * (5.18419064 / 6.1901412));
            Vector2 p18 = fun.Polar(p20, 0.45318417, (d1 / 2 / Math.Sin(eper_ / 2)) * (3.60860647 / 6.1901412));
            Vector2 p19 = fun.Polar(p20, 0.19035835, (d1 / 2 / Math.Sin(eper_ / 2)) * (3.61341811 / 6.1901412));
            Vector2 p21 = fun.Polar(p20, -0.71038756, (d1 / 2 / Math.Sin(eper_ / 2)) * (2.24402478 / 6.1901412));
            Vector2 p22 = fun.Polar(p20, -eper_ / 2, (d1 / 2 / Math.Sin(eper_ / 2)) * (2.20720182 / 6.1901412));
            Vector2 p24 = fun.Polar(p20, -0.41893056, l3 * (9.59919137 / l3bl));
            Vector2 p25 = fun.Polar(p20, 0, l3 * (16.82699742 / l3bl));
            Vector2 p26 = fun.Polar(p25, 0, l3 * (1.59501982 / l3bl));
            Vector2 p15 = fun.Polar(p20, 0.25034044, l3 * (13.66564325 / l3bl));
            Vector2 p14 = fun.Polar(p23, 0, l3 * (29.22546917 / l3bl));
            Vector2 p13 = fun.Polar(p14, 0, l3 * (2.56185074 / l3bl));
            Vector2 p12 = fun.Polar(p16, 0, l3 * (21.70268286 / l3bl));
            Vector2 p11 = fun.Polar(p13, 0.31612558, l3 * (7.77737869 / l3bl));
            Vector2 p10 = fun.Polar(fun.Polar(p20, pi / -2, d1 / 2), 0, l3);
            Vector2 p9 = fun.Polar(p10, pi / 2, d1 * (3.92833974 / 11.74617146));
            Vector2 p8 = fun.Polar(p12, 0, l3 * (13.94860935 / l3bl));
            Vector2 p7 = fun.Polar(p8, -0.10817922, l3 * (15.03813921 / l3bl));
            Vector2 p1 = fun.Polar(p0, pi / 2, d1 / 2);
            Vector2 p2 = fun.mirrorpoint(p1, zx1, zx2);
            Vector2 p3 = fun.Polar(p20, 0.07751593, l2 * (17.61526699 / 20));
            Vector2 p4 = fun.Polar(p3, -0.33459795, l2 * (2.12905222 / 20));
            Vector2 p5 = fun.Polar(p3, -0.81236642, l2 * (2.61234216 / 20));
            Vector2 p6 = fun.Polar(p3, -1.02219996, l2 * (1.98214532 / 20));
            Vector2 p27 = fun.Polar(p20, 0, l3 * (4.34295701 / l3bl));
            Vector2 p28 = fun.Polar(p23, 0, l3 * (14.71985979 / l3bl));
            Vector2 p29 = fun.Polar(p26, 0, l3 * (17.7120858 / l3bl));
            Vector2 p30 = fun.Polar(p16, 0, l3 * (15.29761426 / l3bl));


            Arc arc1 = fun.DrawArc3(p26, p15, p16);
            fun.drawBArc(dxf, arc1, 0.1, contour);
            Arc arc2 = fun.DrawArc3(p27, p24, p28);
            fun.drawBArc(dxf, arc2, 0.1, contour);


            LwPolyline poly1 = new LwPolyline();
            poly1.Vertexes.Add(new LwPolylineVertex(p20));
            poly1.Vertexes.Add(new LwPolylineVertex(p16));
            poly1.Vertexes[1].Bulge = -Math.Tan((0.39599444) / 4);
            poly1.Vertexes.Add(new LwPolylineVertex(p18));
            poly1.Vertexes[2].Bulge = Math.Tan((0.65269103) / 4);
            poly1.Vertexes.Add(new LwPolylineVertex(p17));
            poly1.Vertexes.Add(new LwPolylineVertex(p20));
            poly1.Vertexes.Add(new LwPolylineVertex(p18));
            poly1.Vertexes.Add(new LwPolylineVertex(p19));
            poly1.Vertexes.Add(new LwPolylineVertex(p21));
            poly1.Vertexes.Add(new LwPolylineVertex(p20));
            poly1.Vertexes.Add(new LwPolylineVertex(p22));
            poly1.Vertexes[9].Bulge = Math.Tan((2.96077758) / 4);
            poly1.Vertexes.Add(new LwPolylineVertex(p21));
            poly1.Vertexes.Add(new LwPolylineVertex(p20));
            poly1.Vertexes.Add(new LwPolylineVertex(p23));
            poly1.Vertexes[12].Bulge = Math.Tan((0.76509454) / 4);
            poly1.Vertexes.Add(new LwPolylineVertex(p24));
            fun.PolyFill(dxf, poly1, 0.1, contour);

            Line line1 = new Line(p19, p27);
            fun.drawBline(dxf, line1, 0.1, contour);


            LwPolyline poly2 = new LwPolyline();
            poly2.Vertexes.Add(new LwPolylineVertex(p16));
            poly2.Vertexes[0].Bulge = -Math.Tan((0.64736978) / 4);
            poly2.Vertexes.Add(new LwPolylineVertex(p25));
            poly2.Vertexes[1].Bulge = Math.Tan((0.62295785) / 4);
            poly2.Vertexes.Add(new LwPolylineVertex(p13));
            poly2.Vertexes.Add(new LwPolylineVertex(p28));
            poly2.Vertexes.Add(new LwPolylineVertex(p13));
            poly2.Vertexes[4].Bulge = -Math.Tan((0.72106457) / 4);
            poly2.Vertexes.Add(new LwPolylineVertex(p26));
            poly2.Vertexes[5].Bulge = Math.Tan((0.72106457) / 4);
            poly2.Vertexes.Add(new LwPolylineVertex(p13));
            poly2.Vertexes[6].Bulge = Math.Tan((0.67021515) / 4);
            poly2.Vertexes.Add(new LwPolylineVertex(p11));
            fun.PolyFill(dxf, poly2, 0.1, contour);



            LwPolyline poly3 = new LwPolyline();
            poly3.Vertexes.Add(new LwPolylineVertex(p15));
            poly3.Vertexes[0].Bulge = -Math.Tan((0.78249950) / 4);
            poly3.Vertexes.Add(new LwPolylineVertex(p30));
            poly3.Vertexes.Add(new LwPolylineVertex(p12));
            poly3.Vertexes[2].Bulge = -Math.Tan((0.60021668) / 4);
            poly3.Vertexes.Add(new LwPolylineVertex(p29));
            poly3.Vertexes[3].Bulge = Math.Tan((0.60021668) / 4);
            poly3.Vertexes.Add(new LwPolylineVertex(p12));
            poly3.Vertexes.Add(new LwPolylineVertex(p8));
            poly3.Vertexes[5].Bulge = -Math.Tan((0.68113862) / 4);
            poly3.Vertexes.Add(new LwPolylineVertex(p9));
            poly3.Vertexes.Add(new LwPolylineVertex(p10));
            poly3.Vertexes.Add(new LwPolylineVertex(p2));
            poly3.Vertexes.Add(new LwPolylineVertex(p1));
            poly3.Vertexes.Add(new LwPolylineVertex(p3));
            fun.PolyFill(dxf, poly3, 0.1, contour);


            LwPolyline poly4 = new LwPolyline();
            poly4.Vertexes.Add(new LwPolylineVertex(p4));
            poly4.Vertexes[0].Bulge = -Math.Tan((2.82710171) / 4);
            poly4.Vertexes.Add(new LwPolylineVertex(p5));
            poly4.Vertexes[1].Bulge = -Math.Tan((0.41473805) / 4);
            poly4.Vertexes.Add(new LwPolylineVertex(p6));
            fun.PolyFill(dxf, poly4, 0.1, contour);


            Arc arc3 = fun.DrawArc3(p6, p7, p8);
            fun.drawBArc(dxf, arc3, 0.1, contour);
            Arc arc4 = fun.DrawArc3(p4, p3, p7);
            fun.drawBArc(dxf, arc4, 0.1, contour);
            Arc arc5 = fun.DrawArc3(p29, p11, p10);
            fun.drawBArc(dxf, arc5, 0.1, contour);

            Line line2 = new Line(zx1, zx2);
            line2.Lineweight = Lineweight.W25;//Lineweight指线宽
            line2.Layer = center;//Layer指图层
            line2.Linetype = Linetype.DashDot;//Linetype指是点划线还是虚线什么的
            dxf.AddEntity(line2);



            Milling_cutter.Milling_shankDictionary(dxf, p0, d2, 2, l1, l1 - l4 - (((d2 - d1) / 2)), d1,data);

            //标注
            fun.dimrot1(dxf, p20, p10, 180, d1/2 +10, 2, 1.2, 1.6, 0.9, "  l3=" + l3/scale , "", "");
            fun.dimrot1(dxf, p20, fun.Polar(p20, 0, l2), 180, d1/2+20, 2, 1.2, 1.6, 0.9, "  l2=" + l2 / scale, "", "");
            fun.dimrot1(dxf, p20, fun.Polar(p20, 0, l1), 180, d1/2+30, 2, 1.2, 1.6, 0.9, "  l1=" + l1 / scale, "", "");
            fun.dimrot1(dxf, p16, p23, 90, d1, 2, 1.2, 1.6, 0.9, "  d1=" + d1 / scale, "", "");



            double isframe = Convert.ToInt32(data["isframe"]);
            String isframe_chose = Convert.ToString(data["isframe_chose"]);
            
            if (isframe == 1)
            {
                if (isframe_chose.Equals("0"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA0X(dxf, new Vector2(p0.X - 1189 / 2.0, p0.Y + 841 / 2.0), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }

                if (isframe_chose.Equals("1"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA1X(dxf, new Vector2(p0.X - 841 / 2.0, p0.Y + 594 / 2.0), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }

                if (isframe_chose.Equals("2"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA2X(dxf, new Vector2(p0.X - 594 / 2.0, p0.Y + 420 / 2.0), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }

                if (isframe_chose.Equals("3"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA3X(dxf, new Vector2(p0.X - 420 / 2.0, p0.Y + 297 / 2.0), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }

                if (isframe_chose.Equals("4X"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA4X(dxf, new Vector2(p0.X - 297 / 2.0, p0.Y + 210 / 2.0 - 10 * 2.26), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }

                if (isframe_chose.Equals("4Y"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA4Y(dxf, new Vector2(p0.X - 210 / 2.0, p0.Y + 297 / 2.0), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }
            }


            fun.SetLayer(dxf);
            fun.SetByLayer(dxf);

            dxf.DrawingVariables.AcadVer = DxfVersion.AutoCad2007;
            dxf.Save(path);
        }

        public static void Integratedstepdrill(Dictionary<string, Object> data)    //整体阶梯钻
        {
            DxfDocument dxf = new DxfDocument();
            dxf.Layers["0"].Lineweight = Lineweight.W25;
            Layer contour = new Layer("contour");//轮廓层
            Layer dimensioning = new Layer("dimensioning");//尺寸层
            Layer refin = new Layer("refin");//基准线/内轮廓/虚线
            Layer center = new Layer("center");//中心线
            Layer textlayer = new Layer("textlayer");//文本层
            Layer hatching = new Layer("hatching");//填充层
            Layer additionalline = new Layer("additionalline");//附加线
            Layer cutting = new Layer("cutting");//切削层
            fun.SetLayer(dxf);
            double pi = Math.PI;
            string path = Convert.ToString(data["path"]);
            /*
            double oal = 222.5;
            double dc_1 = 8;
            double dc_2 = 16;
            double dc_3 = 24;
            double pl = 3;
            double sdl_1 = 16;
            double sdl_2 = 32;
            double lcf = 96+58.5;
            double sd_2 = 23.5;
            double sd_3 = 58.5;
            double lf = 219.5;
            double ls = 64;
            double dconms = 24;
            double sta_2 = 106.26;
            double sta_3 = 106.26;

            double sig = 106.26;
            double fha = 25;
            */

            double scale = Convert.ToDouble(data["scale"]); //放大系数
            double oal = Convert.ToDouble(data["oal"])* scale;
            double dc_1 = Convert.ToDouble(data["dc_1"]) * scale;
            double dc_2 = Convert.ToDouble(data["dc_2"]) * scale;
            double dc_3 = Convert.ToDouble(data["dc_3"]) * scale;
            double pl = Convert.ToDouble(data["pl"]) * scale;
            double sdl_1 = Convert.ToDouble(data["sdl_1"]) * scale;
            double sdl_2 = Convert.ToDouble(data["sdl_2"]) * scale;
            double lcf = Convert.ToDouble(data["lcf"]) * scale;
            double sd_2 = Convert.ToDouble(data["sd_2"]) * scale;
            double sd_3 = Convert.ToDouble(data["sd_3"]) * scale;
            double lf = Convert.ToDouble(data["lf"]) * scale;
            double ls = Convert.ToDouble(data["ls"]) * scale;
            double dconms = Convert.ToDouble(data["dconms"]) * scale;
            double sta_2 = Convert.ToDouble(data["sta_2"]);
            double sta_3 = Convert.ToDouble(data["sta_3"]);
            double sig = Convert.ToDouble(data["sig"]);
            double fha = Convert.ToDouble(data["fha"]);
            double fha_ = fha * pi / 180;
            double sta_2_ = sta_2 * pi / 180;
            double sta_3_ = sta_3 * pi / 180;
            double sig_ = sig * pi / 180;

            Vector2 p0 = new Vector2(0, 0);
            Vector2 p0_1 = fun.Polar(p0, 0, oal + 5);
            Vector2 p0_2 = fun.Polar(p0, pi, 5);
            Vector2 p1 = fun.Polar(p0, sig_ / 2.0, (Math.Sqrt(Math.Pow(dc_1 / 2.0, 2) + Math.Pow(pl, 2))));
            Vector2 p2 = fun.mirrorpoint(p1, p0_1, p0_2);
            Vector2 v1 = fun.Polar(p0, -10 * pi / 180, oal);
            Vector2 v1_ = fun.Polar(p2, pi / 2, oal);
            Vector2 p3 = fun.Inters(p0, v1, p2, v1_);
            Vector2 v1_1 = fun.Polar(p1, pi / 2, 0.0001);
            Vector2 v1_2 = new Vector2(v1_1.X + oal + 5, v1_1.Y);
            Line line1 = new Line(v1_1, v1_2);
            Vector2 v5 = fun.Polar(p2, fha_, oal);
            Vector2 v5_1 = fun.Polar(p2, 0, dc_1 / 10);
            Vector2 v5_2 = fun.Polar(v5_1, fha_, oal + 5);
            Line line2 = new Line(v5_2, v5_1);
            Vector2 p5 = fun.Inters(p2, v5, p0_1, p0_2);
            //Vector2 p5 = fun.Polar(p0, 0, p1.X + sdl_1 / 2.0);
            Line line3 = new Line(fun.Polar(p2, 0, dc_1 / 10), p5);
            Vector2 p6 = fun.Polar(p5, pi, dc_1 / 10);
            Vector2 v7 = fun.Polar(p5, pi / 2 + 15 * pi / 180, oal);
            Vector2 p7 = fun.Inters(p5, v7, v1_1, v1_2);
            Vector2 v7_1 = fun.Polar(p7, pi, dc_1 / 10);
            Vector2 v7_2 = fun.Polar(v7_1, pi + fha_, oal);
            Line line4 = new Line(v7_1, v7_2);
            Arc arc4 = fun.DrawArc5(p7, line4, p3);
            Vector2 p4 = fun.Inters1(p1, fun.Polar(p1, -fha_ / 2, oal), arc4, 0);
            Vector2 p8 = fun.PointRotate(p5, p2, pi);
            Vector2 v8_1 = fun.Polar(p8, pi, dc_1 / 10);
            Vector2 v8_2 = fun.Polar(v8_1, pi + fha_, oal + 5);
            Line line5 = new Line(v8_1, v8_2);
            Line line6 = new Line(p8, p6);
            Line line7 = new Line(p7, p8);
            Vector2 v9_ = fun.Polar(p2, pi / 2, (p5.Y - p2.Y) / 3.0);
            Vector2 v9_1 = fun.Polar(v9_, 0, oal + 5);
            Arc arc2 = fun.DrawArc5(p2, line2, p5);
            Vector2 p9 = fun.Inters1(v9_, v9_1, arc2, 1);
            Vector2 p10 = fun.Polar(p2, 0, sdl_1 + p1.X / 2.0);
            Vector2 v11 = fun.Polar(p3, 0, oal + 5);
            Vector2 v11_ = fun.Polar(p10, pi / 2, oal + 5);
            Vector2 p11 = fun.Inters(p3, v11, p10, v11_);
            Vector2 v2_1 = fun.Polar(p2, pi / -2, 0.001);
            Vector2 v2_2 = new Vector2(v2_1.X + oal + 5, v2_1.Y);
            Line line8 = new Line(v2_1, v2_2);
            Arc arc7 = fun.DrawArc5(p9, line8, p11);
            Line line9 = new Line(p10, p11);
            var polyline4 = Pus.AddPointsToLwPolyLine(p1, p0, p2, p3, p0);
            Arc arc1 = fun.DrawArc5(p4, line1, p1);
            Vector2 v12 = fun.Polar(p10, pi / 2, 0.001);
            Vector2 v12_ = fun.Polar(v12, pi, oal);
            Vector2 p12 = fun.Inters1(v12, v12_, arc7, 0);
            Line line10 = new Line(p10, p12);
            Vector2 p13 = fun.Polar(p10, sta_2_ / -2.0, Math.Sqrt(Math.Pow(((dc_2 - dc_1) / 2.0), 2) + (Math.Pow((sd_2 - sdl_1 - pl), 2))));
            Vector2 p14 = fun.mirrorpoint(p13, p0_1, p0_2);
            Line line11 = new Line(p10, p13);
            Line line12 = new Line(p8, p14);
            Vector2 v15 = fun.Polar(p13, pi / 2 - 10 * pi / 180, oal + 5);
            Vector2 v15_1 = fun.Polar(p11, pi / -2, 0.1);
            Vector2 v15_2 = new Vector2(v15_1.X + oal + 5, v15_1.Y);
            Line line13 = new Line(v15_1, v15_2);
            Vector2 p15 = fun.Inters(p0_1, p0_2, p13, v15);
            Vector2 v15_3 = fun.Polar(p15, 0, dc_2 / 10.0);
            Vector2 v15_4 = fun.Polar(v15_3, pi / -2 - 10 * pi / 180, oal + 5);
            Line line14 = new Line(v15_3, v15_4);
            Vector2 v16 = fun.Polar(p13, fha_, oal + 5);
            Vector2 v16_1 = fun.Polar(p13, 0, dc_1 / 10);
            Vector2 v16_2 = fun.Polar(v16_1, fha_, oal + 5);
            Line line15 = new Line(v16_1, v16_2);
            Vector2 p16 = fun.Inters(p13, v16, p0_1, p0_2);
            Vector2 p17 = fun.Polar(p16, pi, dc_2 / 10);
            Vector2 v18 = fun.Polar(p16, pi / 2 + 15 * pi / 180, oal);
            Vector2 v14_1 = fun.Polar(p14, pi / 2, 0.01);
            Vector2 v14_2 = fun.Polar(v14_1, 0, oal + 5);
            Line line16 = new Line(v14_1, v14_2);
            Vector2 p18 = fun.Inters(p16, v18, v14_1, v14_2);
            Vector2 v18_1 = fun.Polar(p18, pi, dc_2 / 10);
            Vector2 v18_2 = fun.Polar(v18_1, pi + fha_, oal);
            Line line17 = new Line(v18_1, v18_2);
            Arc arc10 = fun.DrawArc5(p18, line17, p15);
            Vector2 p19 = fun.Inters1(p14, fun.Polar(p14, -fha_ / 2, oal), arc10, 0);
            Vector2 p20 = fun.PointRotate(p16, p13, pi);
            Vector2 v20_1 = fun.Polar(p20, pi, dc_2 / 10);
            Vector2 v20_2 = fun.Polar(v20_1, pi + fha_, oal + 5);
            Line line18 = new Line(v20_1, v20_2);
            Line line19 = new Line(p19, p17);
            Line line20 = new Line(p18, p20);
            Vector2 v21_ = fun.Polar(p13, pi / 2, (p16.Y - p13.Y) / 4.0);
            Vector2 v21_1 = fun.Polar(v21_, 0, oal + 5);
            Vector2 v13_1 = fun.Polar(p13, 0, dc_2 / 10);
            Vector2 v13_2 = fun.Polar(v13_1, fha_, oal + 5);
            Line line21 = new Line(v13_1, v13_2);
            Arc arc11 = fun.DrawArc5(p13, line21, p16);
            Vector2 p21 = fun.Inters1(v21_, v21_1, arc11, 1);
            Vector2 p22 = fun.Polar(p13, 0, sdl_2 + p15.X - p11.X);
            Vector2 v23 = fun.Polar(p11, 0, oal + 5);
            Vector2 v23_ = fun.Polar(p22, pi / 2, oal + 5);
            Vector2 p23 = fun.Inters(p11, v23, p22, v23_);
            Vector2 v13_3 = fun.Polar(p13, pi / -2, 0.01);
            Vector2 v13_4 = fun.Polar(v13_3, 0, oal + 5);
            Line line22 = new Line(v13_3, v13_4);
            Arc arc12 = fun.DrawArc5(p21, line22, p23);
            Line line23 = new Line(p22, p23);
            Arc arc13 = fun.DrawArc5(p19, line16, p14);
            Vector2 v24 = fun.Polar(p22, pi / 2, 0.001);
            Vector2 v24_ = fun.Polar(v24, pi, oal);
            Vector2 p24 = fun.Inters1(v24, v24_, arc12, 0);
            Line line24 = new Line(p22, p24);
            Vector2 p25 = fun.Polar(p22, sta_3_ / -2.0, Math.Sqrt(Math.Pow(((dc_3 - dc_2) / 2.0), 2) + (Math.Pow((sd_3 - sd_2 - sdl_2), 2))));
            Vector2 p26 = fun.mirrorpoint(p25, p0_1, p0_2);
            Line line25 = new Line(p22, p25);
            Line line26 = new Line(p20, p26);
            Vector2 v27 = fun.Polar(p25, pi / 2 - 20 * pi / 180, oal + 5);
            Vector2 p27 = fun.Inters(p0_1, p0_2, p25, v27);
            Vector2 v27_3 = fun.Polar(p27, 0, 0.1);
            Vector2 v27_4 = fun.Polar(v27_3, pi / -2 + 5 * pi / 180, oal + 5);
            Line line28 = new Line(v27_3, v27_4);
            Arc arc14 = fun.DrawArc5(p25, line28, p27);
            Line line29 = new Line(fun.Polar(p13, 0, dc_2 / 10), p16);
            Vector2 v23_1 = fun.Polar(p23, pi / -2, 0.01);
            Vector2 v23_2 = fun.Polar(v23_1, 0, oal);
            Line line30 = new Line(v23_1, v23_2);

            Vector2 p28 = fun.Polar(p27, 0, (lcf - sd_3) / 4.0);
            Vector2 v28_1 = fun.Polar(p28, 0, 0.1);
            Vector2 v28_2 = fun.Polar(v28_1, pi + fha_ * 1.5, oal);
            Line line31 = new Line(v28_1, v28_2);
            Arc arc19 = fun.DrawArc5(p25, line31, p28);
            Vector2 v29_1 = fun.Polar(p27, 0, (lcf - sd_3) / 4 * 3);
            Vector2 v29_2 = fun.Polar(v29_1, pi / 2, oal);
            Vector2 v29_3 = fun.Polar(fun.Polar(p26, pi / -2, dc_3 / 8), 0, oal);
            Vector2 p29 = fun.Inters(v29_1, v29_2, fun.Polar(p26, pi / -2, dc_3 / 8), v29_3);
            //Vector2 p29 = fun.PointRotate(p28, p25, pi);
            Arc arc20 = fun.DrawArc4(p29, arc19.Radius, p28, 0);
            Vector2 p30 = fun.Polar(p28, pi, (p28.X - p27.X) / 8.0);
            Vector2 v30_1 = fun.Polar(p25, 0, 0.1);
            Vector2 v30_2 = fun.Polar(p25, fha_ / 2, oal);
            Line line32 = new Line(v30_1, v30_2);
            Arc arc21 = fun.DrawArc5(p25, line32, p30);
            Arc arc22 = fun.DrawArc4(p29, arc21.Radius, p30, 0);
            Vector2 v31_1 = fun.Polar(p28, pi / 2 - 15 * pi / 180, oal);
            Vector2 v31_2 = fun.Polar(p26, 0, oal);
            Vector2 p31 = fun.Inters(p28, v31_1, p26, v31_2);
            Vector2 v31_3 = fun.Polar(p31, pi / 2, 0.1);
            Vector2 v31_4 = fun.Polar(v31_3, pi + 5 * pi / 180, oal);
            Line line33 = new Line(v31_3, v31_4);
            Arc arc23 = fun.DrawArc5(p31, line33, p27);
            Vector2 p32 = fun.Inters1(p26, fun.Polar(p26, -fha_ / 2, oal), arc23, 0);
            Vector2 v32_1 = fun.Polar(p26, pi / 2, 0.1);
            Vector2 v32_2 = fun.Polar(v32_1, -5 * pi / 180, oal);
            Line line34 = new Line(v32_2, v32_1);
            Arc arc24 = fun.DrawArc5(p32, line34, p26);
            Vector2 p33 = fun.Inters1(fun.Polar(p31, pi / -2, 0.299), fun.Polar(fun.Polar(p31, pi / -2, 0.299), 0, oal), arc22, 0);
            Line line35 = new Line(p31, p33);
            Vector2 v34 = fun.Polar(p25, pi / 2, dc_3 / 2.0 / 4.0);
            Vector2 v34_ = fun.Polar(v34, 0, oal);
            Vector2 p34 = fun.Inters1(v34, v34_, arc19, 1);
            Vector2 p35 = fun.Inters(p0_1, p0_2, p33, fun.Polar(p33, pi / -2, oal));
            Vector2 v35_1 = fun.Polar(p25, pi / 2, 1);
            Vector2 v35_2 = fun.Polar(v35_1, 0, oal);
            Line line36 = new Line(v35_1, v35_2);
            Arc arc25 = fun.DrawArc5(p34, line36, p35);
            Vector2 v36 = fun.Polar(p35, fha_, oal);
            Vector2 v36_1 = fun.Polar(p33, 0, oal);
            Vector2 p36 = fun.Inters(p35, v36, p33, v36_1);
            Arc arc26 = fun.DrawArc3(p36, p29, p35);
            Vector2 p37 = fun.Polar(p26, 0, oal - ls - sd_3);
            Vector2 p38 = fun.mirrorpoint(p37, p0_1, p0_2);
            Vector2 p39 = fun.Polar(p37, pi, (oal - ls - sd_3) / 25.0);
            Line line37 = new Line(p36, p37);
            Line line38 = new Line(p37, p38);
            Vector2 v40_1 = fun.Polar(p25, pi / 2, 1.01);
            Vector2 v40_2 = fun.Polar(v40_1, 0, oal);
            Vector2 p40 = fun.Inters1(v40_1, v40_2, arc25, 1);
            Vector2 v41 = fun.Polar(p29, pi / -2 - pi / 6, oal);
            Vector2 v41_ = fun.Polar(p40, 0, oal);
            Vector2 p41 = fun.Inters(p40, v41_, p29, v41);
            Line line39 = new Line(p40, p41);
            Vector2 v41_1 = fun.Polar(p41, 0, (oal - ls - sd_3) / 20.0);
            Vector2 v41_2 = fun.Polar(v41_1, fha_ * 1.5, oal);
            Line line40 = new Line(v41_1, v41_2);
            Arc arc27 = fun.DrawArc5(p41, line40, p39);
            Vector2 v42_1 = fun.Polar(p38, pi, oal);
            Vector2 v42_2 = fun.Polar(p39, pi / -2 - 11 * pi / 180, oal);
            Vector2 p42 = fun.Inters(p38, v42_1, p39, v42_2);
            Vector2 v43 = fun.Polar(p41, fha_ * 1.1, oal);
            Vector2 p43 = fun.Inters(p41, v43, p0_1, p0_2);
            Vector2 v43_1 = fun.Polar(v41_1, fha_ * 1.25, oal);
            Line line41 = new Line(v41_1, v43_1);
            Line line42 = new Line(p38, p42);
            Arc arc28 = fun.DrawArc5(p41, line41, p43);
            Vector2 p44 = fun.Polar(p43, -35 * pi / 180, 9.76 / 2.0 / 24.0 * dc_3);
            Vector2 v45 = fun.Polar(p34, 0, oal);
            Vector2 p45 = fun.Inters1(p34, v45, arc28, 1);
            Vector2 p46 = fun.Polar(p44, 0 * pi / 180, 5.0342 / 24.0 * dc_3);
            Vector2 v45_1 = fun.Polar(p42, pi / -2, 0.01);
            Vector2 v45_2 = fun.Polar(v45_1, pi, oal);
            Line line44 = new Line(v45_1, v45_2);
            Arc arc29 = fun.DrawArc5(p45, line44, p42);
            /* Ellipse ellipse00 = new Ellipse(p44, 10.8/24*dc_3 , 9.76 / 24 * dc_3 );//椭圆
             ellipse00.Rotation = 55;
             ellipse00.EndAngle = 90;
             ellipse00.StartAngle = -55;
             ellipse00.Layer = contour;
             ellipse00.Lineweight = Lineweight.W50;
             dxf.AddEntity(ellipse00);
             */
            var polyline6 = Pus.AddPointsToLwPolyLine(p43, p46);
            polyline6.Vertexes[0].Bulge = Math.Tan(146 * pi / 180);
            Vector2 v46_1 = fun.Polar(p42, 0, (oal - ls - sd_3) / 20.0 / 2.0);
            Vector2 v46_2 = fun.Polar(v46_1, fha_ * 3.0, oal);
            Line line43 = new Line(v46_1, v46_2);
            Arc arc30 = fun.DrawArc5(p42, line43, p46);
            Vector2 p47 = fun.Polar(p37, 0, ls - 1 / 64 * ls);
            Vector2 p48 = fun.mirrorpoint(p47, p0_1, p0_2);
            Vector2 p49 = fun.Polar(p47, pi / -4, Math.Sqrt(2) / 64 * ls);
            Vector2 p50 = fun.mirrorpoint(p49, p0_1, p0_2);
            var polyline2 = Pus.AddPointsToLwPolyLine(p37, p47, p49, p50, p48, p47, p48, p38); ;

            for (double i = 0; i < 2; i++)
            {
                Vector2 i0 = new Vector2(-oal * 1.5, 0);
                Vector2 i0_1 = fun.Polar(i0, 0, sd_2 * 10 + 5);
                Vector2 i0_2 = fun.Polar(i0, pi, 5);
                Vector2 i1 = fun.Polar(i0, sig_ / 2.0, (Math.Sqrt(Math.Pow(dc_1 / 2.0, 2) + Math.Pow(pl, 2))) * 5);
                Vector2 i2 = fun.mirrorpoint(i1, i0_1, i0_2);
                Vector2 u1 = fun.Polar(i0, -10 * pi / 180, oal);
                Vector2 u1_ = fun.Polar(i2, pi / 2, oal);
                Vector2 i3 = fun.Inters(i0, u1, i2, u1_);
                Vector2 u1_1 = fun.Polar(i1, pi / 2, 0.0001 * 5);
                Vector2 u1_2 = new Vector2(u1_1.X + oal + 5, u1_1.Y);
                Line line45 = new Line(u1_1, u1_2);
                Vector2 u5 = fun.Polar(i2, fha_, oal * 5);
                Vector2 u5_1 = fun.Polar(i2, 0, dc_1 / 10 * 5);
                Vector2 u5_2 = fun.Polar(u5_1, fha_, (oal + 5) * 5);
                Line line46 = new Line(u5_2, u5_1);
                Vector2 i5 = fun.Inters(i2, u5, i0_1, i0_2);
                //Vector2 p5 = fun.Polar(p0, 0, p1.X + sdl_1 / 2.0);
                Line line47 = new Line(fun.Polar(i2, 0, (dc_1 / 10) * 5), i5);
                Vector2 i6 = fun.Polar(i5, pi, dc_1 / 10 * 5);
                Vector2 u7 = fun.Polar(i5, pi / 2 + 15 * pi / 180, oal * 5);
                Vector2 i7 = fun.Inters(i5, u7, u1_1, u1_2);
                Vector2 u7_1 = fun.Polar(i7, pi, dc_1 / 10 * 5);
                Vector2 u7_2 = fun.Polar(u7_1, pi + fha_, oal * 5);
                Line line48 = new Line(u7_1, u7_2);
                Arc arc4_ = fun.DrawArc5(i7, line48, i3);
                Vector2 i4 = fun.Inters1(i1, fun.Polar(i1, -fha_ / 2, oal * 5), arc4_, 0);
                Vector2 i8 = fun.PointRotate(i5, i2, pi);
                Vector2 u8_1 = fun.Polar(i8, pi, dc_1 / 10 * 5);
                Vector2 u8_2 = fun.Polar(u8_1, pi + fha_, (oal + 5) * 5);
                Line line49 = new Line(u8_1, u8_2);
                Line line50 = new Line(i8, i6);
                Line line51 = new Line(i7, i8);
                Vector2 u9_ = fun.Polar(i2, pi / 2, (i5.Y - i2.Y) / 3.0);
                Vector2 u9_1 = fun.Polar(u9_, 0, (oal + 5) * 5);
                Arc arc2_ = fun.DrawArc5(i2, line46, i5);
                Vector2 i9 = fun.Inters1(u9_, u9_1, arc2_, 1);
                Vector2 i10 = fun.Polar(i2, 0, (sdl_1 + p1.X / 2.0) * 5);
                Vector2 u11 = fun.Polar(i3, 0, oal + 5);
                Vector2 u11_ = fun.Polar(i10, pi / 2, oal + 5);
                Vector2 i11 = fun.Inters(i3, u11, i10, u11_);
                Vector2 u2_1 = fun.Polar(i2, pi / -2, 0.001 * 5);
                Vector2 u2_2 = new Vector2(u2_1.X + oal + 5, u2_1.Y);
                Line line52 = new Line(u2_1, u2_2);
                Arc arc7_ = fun.DrawArc5(i9, line52, i11);
                Line line53 = new Line(i10, i11);
                var polyline5 = Pus.AddPointsToLwPolyLine(i1, i0, i2, i3, i0);
                Arc arc1_ = fun.DrawArc5(i4, line45, i1);
                Vector2 u12 = fun.Polar(i10, pi / 2, 0.001 * 5);
                Vector2 u12_ = fun.Polar(u12, pi, oal);
                Vector2 i12 = fun.Inters1(u12, u12_, arc7_, 0);
                Line line54 = new Line(i10, i12);
                Vector2 i13 = fun.Polar(i10, sta_2_ / -2.0, Math.Sqrt(Math.Pow(((dc_2 - dc_1) / 2.0), 2) + (Math.Pow((sd_2 - sdl_1 - pl), 2))) * 5);
                Vector2 i14 = fun.mirrorpoint(i13, i0_1, i0_2);
                Line line55 = new Line(i10, i13);
                Line line56 = new Line(i8, i14);
                Vector2 u15 = fun.Polar(i13, pi / 2 - 10 * pi / 180, oal + 5);
                Vector2 u15_1 = fun.Polar(i11, pi / -2, 0.1 * 5);
                Vector2 u15_2 = new Vector2(u15_1.X + oal + 5, v15_1.Y);
                Line line57 = new Line(u15_1, u15_2);
                Vector2 i15 = fun.Inters(i0_1, i0_2, i13, u15);
                Vector2 u15_3 = fun.Polar(i15, 0, dc_2 / 10.0);
                Vector2 u15_4 = fun.Polar(u15_3, pi / -2 - 10 * pi / 180, oal + 5);
                Line line58 = new Line(u15_3, u15_4);

                Vector2 u16 = fun.Polar(i13, fha_, oal + 5);
                Vector2 u16_1 = fun.Polar(i13, 0, dc_1 / 10 * 5);
                Vector2 u16_2 = fun.Polar(u16_1, fha_, oal + 5);
                Line line15_ = new Line(u16_1, u16_2);
                Vector2 i16 = fun.Inters(i13, u16, i0_1, i0_2);
                Vector2 i17 = fun.Polar(i16, pi, dc_2 / 10 * 5);
                Vector2 u18 = fun.Polar(i16, pi / 2 + 15 * pi / 180, oal);
                Vector2 u14_1 = fun.Polar(i14, pi / 2, 0.01 * 5);
                Vector2 u14_2 = fun.Polar(u14_1, 0, oal + 5);
                Line line16_ = new Line(u14_1, u14_2);
                Vector2 i18 = fun.Inters(i16, u18, u14_1, u14_2);
                Vector2 u18_1 = fun.Polar(i18, pi, dc_2 / 10 * 5);
                Vector2 u18_2 = fun.Polar(u18_1, pi + fha_, oal);
                Line line17_ = new Line(u18_1, u18_2);
                Arc arc10_ = fun.DrawArc5(i18, line17_, i15);
                Vector2 i19 = fun.Inters1(i14, fun.Polar(i14, -fha_ / 2, oal), arc10_, 0);
                Vector2 i20 = fun.PointRotate(i16, i13, pi);
                Vector2 u20_1 = fun.Polar(i20, pi, dc_2 / 10 * 5);
                Vector2 u20_2 = fun.Polar(u20_1, pi + fha_, oal + 5);
                Line line18_ = new Line(u20_1, u20_2);
                Line line19_ = new Line(i19, i17);
                Line line20_ = new Line(i18, i20);
                Vector2 u21_ = fun.Polar(i13, pi / 2, (i16.Y - i13.Y) / 4.0);
                Vector2 u21_1 = fun.Polar(u21_, 0, oal + 5);
                Vector2 u13_1 = fun.Polar(i13, 0, dc_2 / 10 * 5);
                Vector2 u13_2 = fun.Polar(u13_1, fha_, oal + 5);
                Line line21_ = new Line(u13_1, u13_2);
                Arc arc11_ = fun.DrawArc5(i13, line21_, i16);
                Vector2 i21 = fun.Inters1(u21_, u21_1, arc11_, 1);
                Vector2 i22 = fun.Polar(i13, 0, sdl_2 * 5 + p15.X - p11.X);
                Vector2 u23 = fun.Polar(i11, 0, oal + 5);
                Vector2 u23_ = fun.Polar(i22, pi / 2, oal + 5);
                Vector2 i23 = fun.Inters(i11, u23, i22, u23_);
                Vector2 u13_3 = fun.Polar(i13, pi / -2, 0.01 * 5);
                Vector2 u13_4 = fun.Polar(u13_3, 0, oal + 5);
                Line line22_ = new Line(u13_3, u13_4);
                Arc arc12_ = fun.DrawArc5(i21, line22_, i23);
                Line line23_ = new Line(i22, i23);
                Arc arc13_ = fun.DrawArc5(i19, line16_, i14);
                Vector2 u24 = fun.Polar(i22, pi / 2, 0.001 * 5);
                Vector2 u24_ = fun.Polar(u24, pi, oal);
                Vector2 i24 = fun.Inters1(u24, u24_, arc12_, 0);
                Arc arc12_1 = fun.DrawArc4(i21, arc12_.Radius, i24, 0);
                Line line29_ = new Line(fun.Polar(i13, 0, dc_2 / 10 * 5), i16);



                Arc arc3_ = fun.DrawArc5(i2, line47, i6);
                Arc arc5_ = fun.DrawArc4(i8, arc3_.Radius, i6, 0);
                Arc arc6_ = fun.DrawArc4(i8, arc2_.Radius, i5, 0);
                Arc arc8_ = fun.DrawArc5(i11, line57, i15);
                Arc arc9_ = fun.DrawArc5(i13, line58, i15);
                Arc arc15_ = fun.DrawArc5(i13, line29_, i17);
                // Line line100 = new Line(i9, fun.Polar(i9, pi / 2, 100));
                fun.PolyFill(dxf, polyline5, 0.5, contour);
                fun.drawBArc(dxf, arc1_, 0.5, contour);
                fun.drawBArc(dxf, arc2_, 0.5, contour);
                fun.drawBArc(dxf, arc3_, 0.5, contour);
                fun.drawBArc(dxf, arc4_, 0.5, contour);
                fun.drawBArc(dxf, arc5_, 0.5, contour);
                fun.drawBArc(dxf, arc6_, 0.5, contour);
                fun.drawBArc(dxf, arc7_, 0.5, contour);
                fun.drawBArc(dxf, arc8_, 0.5, contour);
                fun.drawBArc(dxf, arc9_, 0.5, contour);
                fun.drawBArc(dxf, arc10_, 0.5, contour);
                fun.drawBArc(dxf, arc11_, 0.5, contour);
                fun.drawBArc(dxf, arc12_1, 0.5, contour);
                fun.drawBArc(dxf, arc13_, 0.5, contour);
                fun.drawBArc(dxf, arc15_, 0.5, contour);
                fun.drawBline(dxf, line51, 0.5, contour);
                fun.drawBline(dxf, line53, 0.5, contour);
                fun.drawBline(dxf, line54, 0.5, contour);
                fun.drawBline(dxf, line55, 0.5, contour);
                fun.drawBline(dxf, line56, 0.5, contour);

                //标注
                Vector2 q1 = fun.Polar(i8, pi / 2, dc_1 * 5 + 15);
                Vector2 q2 = fun.Polar(p37, 0, fun.CalDistance(p47, p37) / 2.0);
                Vector2 q3 = fun.Polar(q2, pi / -2, fun.CalDistance(p48, p47) / 2.0);
                Vector2 q4 = fun.Polar(p0, pi, dconms + dconms);
                Vector2 q5 = fun.Polar(q4, pi / 2, dc_3 * 5);
                Vector2 q6 = fun.Polar(p49, pi / -2, fun.CalDistance(p49, p50) / 2.0);
                Vector2 q7 = fun.Polar(q6, pi / -4, 1.7);
                Vector2 q8 = fun.Polar(q7, pi / -4, dconms * 2);
                Vector2 q9 = fun.Polar(q8, pi / -2, 1.2 * 5);
                Vector2 q10 = fun.Polar(q3, pi + pi / 6, 1.7);
                Vector2 q11 = fun.Polar(q10, pi + pi / 6, dconms * 3);
                Vector2 q12 = fun.Polar(q11, pi / -2, 1.2 * 5);
                Vector2 q13 = fun.Polar(i0, pi + pi / 3, 1.7);
                Vector2 q14 = fun.Polar(q13, pi + pi / 3, dconms * 2);
                Vector2 q15 = fun.Polar(q14, pi / -2, 1.2 * 5);

                Vector2 q16 = fun.Polar(q3, pi / 2, dconms);
                Vector2 q17 = fun.Polar(q16, pi / 4, dconms / 4.0);
                Vector2 q18 = fun.Polar(q17, 0, dconms / 2.0);
                Vector2 q19 = fun.mirrorpoint(q16, p0_1, p0_2);
                Vector2 q20 = fun.mirrorpoint(q17, p0_1, p0_2);
                Vector2 q21 = fun.mirrorpoint(q18, p0_1, p0_2);

                Line linev1 = new Line(q16, q19);
                Line linev2 = new Line(q16, q17);
                Line linev3 = new Line(q17, q18);
                Line linev4 = new Line(q19, q20);
                Line linev5 = new Line(q20, q21);
                Line linev6 = new Line(i0_1, i0_2);
                linev1.Layer = additionalline;//Layer指图层
                linev1.Linetype = Linetype.DashDot;//Linetype指是点划线还是虚线什么的
                linev1.LinetypeScale = 5;//指线性比例
                linev2.Layer = additionalline;//Layer指图层
                linev2.Linetype = Linetype.DashDot;//Linetype指是点划线还是虚线什么的
                linev2.LinetypeScale = 5;//指线性比例
                linev3.Layer = additionalline;//Layer指图层
                linev3.Linetype = Linetype.DashDot;//Linetype指是点划线还是虚线什么的
                linev3.LinetypeScale = 5;//指线性比例
                linev4.Layer = additionalline;//Layer指图层
                linev4.Linetype = Linetype.DashDot;//Linetype指是点划线还是虚线什么的
                linev4.LinetypeScale = 5;//指线性比例
                linev5.Layer = additionalline;//Layer指图层
                linev5.Linetype = Linetype.DashDot;//Linetype指是点划线还是虚线什么的
                linev5.LinetypeScale = 5;//指线性比例

                linev6.Lineweight = Lineweight.W25;//Lineweight指线宽
                linev6.Layer = center;//Layer指图层
                linev6.LinetypeScale = 5;//指线性比例
                linev6.Linetype = Linetype.DashDot;//Linetype指是点划线还是虚线什么的
                dxf.AddEntity(linev6); //提取

                dxf.AddEntity(new EntityObject[] { linev1, linev2, linev3, linev4, linev5 });
                Line line100 = new Line(p0_1, p0_2);
                line100.Lineweight = Lineweight.W25;//Lineweight指线宽
                line100.Layer = additionalline;//Layer指图层
                line100.LinetypeScale = 5;//指线性比例
                line100.Linetype = Linetype.DashDot;//Linetype指是点划线还是虚线什么的
                dxf.AddEntity(line100); //提取

                fun.dimrot1(dxf, i0, i14, 0, dc_1 * 5, 2, 1.2 * 5, 1.6 * 5, 0.9, "SD_2=" + sd_2 / scale, "", "");
                fun.dimrot1(dxf, i1, i8, 0, dc_1 * 5 / 2.0, 2, 1.2 * 5, 1.6 * 5, 0.9, "SDL_1=" + sdl_1 / scale, "", "");
                fun.dimrot1(dxf, i0, i2, 180, dc_1 * 5 / 2.0, 2, 1.2 * 5, 1.6 * 5, 0.9, "PL=" + pl / scale, "", "");
                fun.dimrot1(dxf, fun.Polar(i2, pi, 0.001), i2, 180, dc_1 * 5 / 1.7, 2, 1.2 * 5, 1.6 * 5, 0.9, "LF", "", "");
                fun.dimrot1(dxf, i13, i14, -90, dc_1 * 15, 2, 1.2 * 5, 1.6 * 5, 0.9, "DC_2=" + dc_2 / scale, "", "");
                fun.dimrot1(dxf, i1, i2, 90, dc_1 * 5, 2, 1.2 * 5, 1.6 * 5, 0.9, "DC_1=" + dc_1 / scale, "", "");
                fun.dimrot1(dxf, p49, p0, 0, dc_3 * 7, 2, 1.2 * 5, 1.6 * 5, 0.9, "OAL=" + oal / scale, "", "");
                fun.dimrot1(dxf, q2, p0, 0, dc_3 * 6, 2, 1.2 * 5, 1.6 * 5, 0.9, "LPR", "", "");
                fun.dimrot1(dxf, q2, p1, 0, dc_3 * 5, 2, 1.2 * 5, 1.6 * 5, 0.9, "LTA", "", "");
                fun.dimrot1(dxf, p46, p0, 0, dc_3 * 4, 2, 1.2 * 5, 1.6 * 5, 0.9, "LCF=" + lcf / scale, "", "");
                fun.dimrot1(dxf, fun.Polar(p36, 0, fun.CalDistance(p36, p39) / 2.0), p0, 0, dc_3 * 3, 2, 1.2 * 5, 1.6 * 5, 0.9, "LU", "", "");
                fun.dimrot1(dxf, fun.Polar(p36, 0, fun.CalDistance(p36, p39) / 2.0), p26, 0, dc_3 * 2, 2, 1.2 * 5, 1.6 * 5, 0.9, "SDL_3", "", "");
                fun.dimrot1(dxf, p20, p14, 0, dc_3 * 2 + (p26.Y - p20.Y), 2, 1.2 * 5, 1.6 * 5, 0.9, "SDL_2=" + sdl_2 / scale, "", "");
                fun.dimrot1(dxf, p50, p38, 180, dc_3 * 2, 2, 1.2 * 5, 1.6 * 5, 0.9, "LS=" + ls / scale, "", "");
                fun.dimrot1(dxf, p25, p0, 180, dc_3 * 2 + (p26.Y / 2.0), 2, 1.2 * 5, 1.6 * 5, 0.9, "SD_3=" + sd_3, "", "");
                fun.dimrot1(dxf, p50, p2, 180, dc_3 * 3, 2, 1.2 * 5, 1.6 * 5, 0.9, "LF=" + lf / scale, "", "");
                fun.dimrot1(dxf, p48, p47, -90, dc_3 * 2, 2, 1.2 * 5, 1.6 * 5, 0.9, "DCONMS=" + dconms / scale, "", "");
                fun.dimrot1(dxf, p25, p26, 90, sd_3 * 1.5, 2, 1.2 * 5, 1.6 * 5, 0.9, "DC_3=" + dc_3 / scale, "", "");
                fun.dimrot1(dxf, p14, p0, 0, dc_3 * 2 + (p26.Y - p20.Y) + (p14.Y / 2.0), 2, 1.2 * 5, 1.6 * 5, 0.9, "SD_2=" + sd_2 / scale, "", "");

                fun.jdbz2(dxf, new Line(i0, fun.Polar(i0, pi - sig_ / 2, 0.1)), new Line(i0, fun.Polar(i0, pi + sig_ / 2, 0.1)), dc_1 * 5, 1.2 * 5, 1.6 * 5, 0.9, "SIG=" , "", "0");
                fun.jdbz2(dxf, new Line(i10, i13), new Line(i8, i14), dc_1 * 15 * 1.5, 1.2 * 5, 1.6 * 5, 0.9, "STA_2" ,"", "");
                fun.jdbz2(dxf, new Line(p22, p25), new Line(p20, p26), dc_1 * 5, 1.2 * 5, 1.6 * 5, 0.9, "STA_3", "", "");

                fun.Axis(dxf, fun.Polar(p50, pi / -2, dc_3 * 4), 0, -90, "Z", "X", "Y", 1.0, 1.2 * 5, 1);
                fun.Axis(dxf, q6, 0, -90, "", "", "", 1.0, 1.2 * 5, 1);
                fun.Axis(dxf, q3, 0, -90, "", "", "", 1.0, 1.2 * 5, 1);
                fun.Axis(dxf, i0, 0, -90, "", "", "", 1.0, 1.2 * 5, 1);

                Line lineq1 = new Line(q7, q8);
                Line lineq2 = new Line(q10, q11);
                Line lineq3 = new Line(q13, q14);
                Text txt1 = new Text("Detail A", q1, 1.2 * 5, 2);
                Text txt2 = new Text("ISYC=302_02", fun.Polar(p0, pi / 2, dc_3 * 8), 1.2 * 5, 2);
                Text txt3 = new Text("PCS", q9, 1.2 * 5, 2);
                Text txt4 = new Text("MCS", q12, 1.2 * 5, 2);
                Text txt5 = new Text("CIP", q15, 1.2 * 5, 2);
                dxf.AddEntity(new EntityObject[] { lineq1, lineq2, lineq3, txt1, txt2, txt3, txt4, txt5 });

                fun.Singlelinearrow(dxf, "CCMS", q2, 45, fun.Polar(q2, pi / 4, dconms / 2.0), fun.Polar(q2, pi / 4, dconms), 1.2 * 5, 1.6 * 5);
                fun.Singlelinearrow(dxf, "FDP", q5, 180, fun.Polar(q5, 0, dconms / 2.0), fun.Polar(q5, 0, dconms), 1.2 * 5, 1.6 * 5);

                Ellipse ellipse01 = new Ellipse(fun.Polar(p8, pi / -2, dc_1 / 2.0), dc_3 * 2.5, dc_1 * 4);//椭圆               
                ellipse01.Rotation = 0;
                ellipse01.EndAngle = 90;
                ellipse01.StartAngle = 90;
                ellipse01.Layer = additionalline;
                ellipse01.Linetype = Linetype.DashDot;
                ellipse01.LinetypeScale = 5;
                ellipse01.Lineweight = Lineweight.W50;
                dxf.AddEntity(ellipse01);
            }
            Arc arc3 = fun.DrawArc5(p2, line3, p6);
            Arc arc5 = fun.DrawArc4(p8, arc3.Radius, p6, 0);
            Arc arc6 = fun.DrawArc4(p8, arc2.Radius, p5, 0);
            Arc arc8 = fun.DrawArc5(p11, line13, p15);
            Arc arc9 = fun.DrawArc5(p13, line14, p15);
            Arc arc15 = fun.DrawArc5(p13, line29, p17);
            Arc arc16 = fun.DrawArc4(p20, arc11.Radius, p16, 0);
            Arc arc17 = fun.DrawArc4(p20, arc15.Radius, p17, 0);
            Arc arc18 = fun.DrawArc5(p23, line30, p27);

            fun.drawBArc(dxf, arc1, 0.5, contour);
            fun.drawBArc(dxf, arc2, 0.5, contour);
            fun.drawBArc(dxf, arc3, 0.5, contour);
            fun.drawBArc(dxf, arc4, 0.5, contour);
            fun.drawBArc(dxf, arc5, 0.5, contour);
            fun.drawBArc(dxf, arc6, 0.5, contour);
            fun.drawBArc(dxf, arc7, 0.5, contour);
            fun.drawBArc(dxf, arc8, 0.5, contour);
            fun.drawBArc(dxf, arc9, 0.5, contour);
            fun.drawBArc(dxf, arc10, 0.5, contour);
            fun.drawBArc(dxf, arc11, 0.5, contour);
            fun.drawBArc(dxf, arc12, 0.5, contour);
            fun.drawBArc(dxf, arc13, 0.5, contour);
            fun.drawBArc(dxf, arc14, 0.5, contour);
            fun.drawBArc(dxf, arc15, 0.5, contour);
            fun.drawBArc(dxf, arc16, 0.5, contour);
            fun.drawBArc(dxf, arc17, 0.5, contour);
            fun.drawBArc(dxf, arc18, 0.5, contour);
            fun.drawBArc(dxf, arc19, 0.5, contour);
            fun.drawBArc(dxf, arc20, 0.5, contour);
            fun.drawBArc(dxf, arc21, 0.5, contour);
            fun.drawBArc(dxf, arc22, 0.5, contour);
            fun.drawBArc(dxf, arc23, 0.5, contour);
            fun.drawBArc(dxf, arc24, 0.5, contour);
            fun.drawBArc(dxf, arc25, 0.5, contour);
            fun.drawBArc(dxf, arc26, 0.5, contour);
            fun.drawBArc(dxf, arc27, 0.5, contour);
            fun.drawBArc(dxf, arc28, 0.5, contour);
            fun.drawBArc(dxf, arc29, 0.5, contour);
            fun.drawBArc(dxf, arc30, 0.5, contour);

            fun.PolyFill(dxf, polyline2, 0.5, contour);
            fun.PolyFill(dxf, polyline4, 0.5, contour);
            fun.PolyFill(dxf, polyline6, 0.5, contour);

            fun.drawBline(dxf, line7, 0.5, contour);
            fun.drawBline(dxf, line9, 0.5, contour);
            fun.drawBline(dxf, line10, 0.5, contour);
            fun.drawBline(dxf, line11, 0.5, contour);
            fun.drawBline(dxf, line12, 0.5, contour);
            fun.drawBline(dxf, line20, 0.5, contour);
            fun.drawBline(dxf, line23, 0.5, contour);
            fun.drawBline(dxf, line24, 0.5, contour);
            fun.drawBline(dxf, line25, 0.5, contour);
            fun.drawBline(dxf, line26, 0.5, contour);
            fun.drawBline(dxf, line35, 0.5, contour);
            fun.drawBline(dxf, line37, 0.5, contour);
            fun.drawBline(dxf, line38, 0.5, contour);
            fun.drawBline(dxf, line39, 0.5, contour);
            fun.drawBline(dxf, line42, 0.5, contour);



            double isframe = Convert.ToInt32(data["isframe"]);
            String isframe_chose = Convert.ToString(data["isframe_chose"]);
            
            if (isframe == 1)
            {
                if (isframe_chose.Equals("0"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA0X(dxf, new Vector2(p0.X - 1189 / 2.0, p0.Y + 841 / 2.0), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }

                if (isframe_chose.Equals("1"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA1X(dxf, new Vector2(p0.X - 841 / 2.0, p0.Y + 594 / 2.0), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }

                if (isframe_chose.Equals("2"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA2X(dxf, new Vector2(p0.X - 594 / 2.0, p0.Y + 420 / 2.0), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }

                if (isframe_chose.Equals("3"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA3X(dxf, new Vector2(p0.X - 420 / 2.0, p0.Y + 297 / 2.0), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }

                if (isframe_chose.Equals("4X"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA4X(dxf, new Vector2(p0.X - 297 / 2.0, p0.Y + 210 / 2.0 - 10 * 2.26), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }

                if (isframe_chose.Equals("4Y"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA4Y(dxf, new Vector2(p0.X - 210 / 2.0, p0.Y + 297 / 2.0), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }
            }

            fun.SetLayer(dxf);
            fun.SetByLayer(dxf);
            dxf.DrawingVariables.AcadVer = DxfVersion.AutoCad2007;
            dxf.Save(path);
        }

        public static void ISYC_302_02(Dictionary<string, Object> data)    //整体阶梯钻
        {
            DxfDocument dxf = new DxfDocument();
            dxf.Layers["0"].Lineweight = Lineweight.W25;
            Layer contour = new Layer("contour");//轮廓层
            Layer dimensioning = new Layer("dimensioning");//尺寸层
            Layer refin = new Layer("refin");//基准线/内轮廓/虚线
            Layer center = new Layer("center");//中心线
            Layer textlayer = new Layer("textlayer");//文本层
            Layer hatching = new Layer("hatching");//填充层
            Layer additionalline = new Layer("additionalline");//附加线
            Layer cutting = new Layer("cutting");//切削层
            fun.SetLayer(dxf);
            double pi = Math.PI;
            string path = Convert.ToString(data["path"]);
            /*
            double oal = 222.5;
            double dc_1 = 8;
            double dc_2 = 16;
            double dc_3 = 24;
            double pl = 3;
            double sdl_1 = 16;
            double sdl_2 = 32;
            double lcf = 96 + 58.5;
            double sd_2 = 23.5;
            double sd_3 = 58.5;
            double lf = 219.5;
            double ls = 64;
            double dconms = 24;
            double sta_2 = 106.26;
            double sta_3 = 106.26;
            double sig = 106.26;
            double fha = 25;
            */
            double oal = Convert.ToDouble(data["oal"]);
            double dc_1 = Convert.ToDouble(data["dc_1"]);
            double dc_2 = Convert.ToDouble(data["dc_2"]);
            double dc_3 = Convert.ToDouble(data["dc_3"]);
            double pl = Convert.ToDouble(data["pl"]);
            double sdl_1 = Convert.ToDouble(data["sdl_1"]);
            double sdl_2 = Convert.ToDouble(data["sdl_2"]);
            double lcf = Convert.ToDouble(data["lcf"]);
            double sd_2 = Convert.ToDouble(data["sd_2"]);
            double sd_3 = Convert.ToDouble(data["sd_3"]);
            double lf = Convert.ToDouble(data["lf"]);
            double ls = Convert.ToDouble(data["ls"]);
            double dconms = Convert.ToDouble(data["dconms"]);
            double sta_2 = Convert.ToDouble(data["sta_2"]);
            double sta_3 = Convert.ToDouble(data["sta_3"]);
            double sig = Convert.ToDouble(data["sig"]);
            double fha = Convert.ToDouble(data["fha"]);
            double fha_ = fha * pi / 180;
            double sta_2_ = sta_2 * pi / 180;
            double sta_3_ = sta_3 * pi / 180;
            double sig_ = sig * pi / 180;

            Vector2 p0 = new Vector2(0, 0);
            Vector2 p0_1 = fun.Polar(p0, 0, oal + 5);
            Vector2 p0_2 = fun.Polar(p0, pi, 5);
            Vector2 p1 = fun.Polar(p0, sig_ / 2.0, (Math.Sqrt(Math.Pow(dc_1 / 2.0, 2) + Math.Pow(pl, 2))));
            Vector2 p2 = fun.mirrorpoint(p1, p0_1, p0_2);
            Vector2 v1 = fun.Polar(p0, -10 * pi / 180, oal);
            Vector2 v1_ = fun.Polar(p2, pi / 2, oal);
            Vector2 p3 = fun.Inters(p0, v1, p2, v1_);
            Vector2 v1_1 = fun.Polar(p1, pi / 2, 0.0001);
            Vector2 v1_2 = new Vector2(v1_1.X + oal + 5, v1_1.Y);
            Line line1 = new Line(v1_1, v1_2);
            Vector2 v5 = fun.Polar(p2, fha_, oal);
            Vector2 v5_1 = fun.Polar(p2, 0, dc_1 / 10);
            Vector2 v5_2 = fun.Polar(v5_1, fha_, oal + 5);
            Line line2 = new Line(v5_2, v5_1);
            Vector2 p5 = fun.Inters(p2, v5, p0_1, p0_2);
            //Vector2 p5 = fun.Polar(p0, 0, p1.X + sdl_1 / 2.0);
            Line line3 = new Line(fun.Polar(p2, 0, dc_1 / 10), p5);
            Vector2 p6 = fun.Polar(p5, pi, dc_1 / 10);
            Vector2 v7 = fun.Polar(p5, pi / 2 + 15 * pi / 180, oal);
            Vector2 p7 = fun.Inters(p5, v7, v1_1, v1_2);
            Vector2 v7_1 = fun.Polar(p7, pi, dc_1 / 10);
            Vector2 v7_2 = fun.Polar(v7_1, pi + fha_, oal);
            Line line4 = new Line(v7_1, v7_2);
            Arc arc4 = fun.DrawArc5(p7, line4, p3);
            Vector2 p4 = fun.Inters1(p1, fun.Polar(p1, -fha_ / 2, oal), arc4, 0);
            Vector2 p8 = fun.PointRotate(p5, p2, pi);
            Vector2 v8_1 = fun.Polar(p8, pi, dc_1 / 10);
            Vector2 v8_2 = fun.Polar(v8_1, pi + fha_, oal + 5);
            Line line5 = new Line(v8_1, v8_2);
            Line line6 = new Line(p8, p6);
            Line line7 = new Line(p7, p8);
            Vector2 v9_ = fun.Polar(p2, pi / 2, (p5.Y - p2.Y) / 3.0);
            Vector2 v9_1 = fun.Polar(v9_, 0, oal + 5);
            Arc arc2 = fun.DrawArc5(p2, line2, p5);
            Vector2 p9 = fun.Inters1(v9_, v9_1, arc2, 1);
            Vector2 p10 = fun.Polar(p2, 0, sdl_1 + p1.X / 2.0);
            Vector2 v11 = fun.Polar(p3, 0, oal + 5);
            Vector2 v11_ = fun.Polar(p10, pi / 2, oal + 5);
            Vector2 p11 = fun.Inters(p3, v11, p10, v11_);
            Vector2 v2_1 = fun.Polar(p2, pi / -2, 0.001);
            Vector2 v2_2 = new Vector2(v2_1.X + oal + 5, v2_1.Y);
            Line line8 = new Line(v2_1, v2_2);
            Arc arc7 = fun.DrawArc5(p9, line8, p11);
            Line line9 = new Line(p10, p11);
            var polyline4 = Pus.AddPointsToLwPolyLine(p1, p0, p2, p3, p0);
            Arc arc1 = fun.DrawArc5(p4, line1, p1);
            Vector2 v12 = fun.Polar(p10, pi / 2, 0.001);
            Vector2 v12_ = fun.Polar(v12, pi, oal);
            Vector2 p12 = fun.Inters1(v12, v12_, arc7, 0);
            Line line10 = new Line(p10, p12);
            Vector2 p13 = fun.Polar(p10, sta_2_ / -2.0, Math.Sqrt(Math.Pow(((dc_2 - dc_1) / 2.0), 2) + (Math.Pow((sd_2 - sdl_1 - pl), 2))));
            Vector2 p14 = fun.mirrorpoint(p13, p0_1, p0_2);
            Line line11 = new Line(p10, p13);
            Line line12 = new Line(p8, p14);
            Vector2 v15 = fun.Polar(p13, pi / 2 - 10 * pi / 180, oal + 5);
            Vector2 v15_1 = fun.Polar(p11, pi / -2, 0.1);
            Vector2 v15_2 = new Vector2(v15_1.X + oal + 5, v15_1.Y);
            Line line13 = new Line(v15_1, v15_2);
            Vector2 p15 = fun.Inters(p0_1, p0_2, p13, v15);
            Vector2 v15_3 = fun.Polar(p15, 0, dc_2 / 10.0);
            Vector2 v15_4 = fun.Polar(v15_3, pi / -2 - 10 * pi / 180, oal + 5);
            Line line14 = new Line(v15_3, v15_4);
            Vector2 v16 = fun.Polar(p13, fha_, oal + 5);
            Vector2 v16_1 = fun.Polar(p13, 0, dc_1 / 10);
            Vector2 v16_2 = fun.Polar(v16_1, fha_, oal + 5);
            Line line15 = new Line(v16_1, v16_2);
            Vector2 p16 = fun.Inters(p13, v16, p0_1, p0_2);
            Vector2 p17 = fun.Polar(p16, pi, dc_2 / 10);
            Vector2 v18 = fun.Polar(p16, pi / 2 + 15 * pi / 180, oal);
            Vector2 v14_1 = fun.Polar(p14, pi / 2, 0.01);
            Vector2 v14_2 = fun.Polar(v14_1, 0, oal + 5);
            Line line16 = new Line(v14_1, v14_2);
            Vector2 p18 = fun.Inters(p16, v18, v14_1, v14_2);
            Vector2 v18_1 = fun.Polar(p18, pi, dc_2 / 10);
            Vector2 v18_2 = fun.Polar(v18_1, pi + fha_, oal);
            Line line17 = new Line(v18_1, v18_2);
            Arc arc10 = fun.DrawArc5(p18, line17, p15);
            Vector2 p19 = fun.Inters1(p14, fun.Polar(p14, -fha_ / 2, oal), arc10, 0);
            Vector2 p20 = fun.PointRotate(p16, p13, pi);
            Vector2 v20_1 = fun.Polar(p20, pi, dc_2 / 10);
            Vector2 v20_2 = fun.Polar(v20_1, pi + fha_, oal + 5);
            Line line18 = new Line(v20_1, v20_2);
            Line line19 = new Line(p19, p17);
            Line line20 = new Line(p18, p20);
            Vector2 v21_ = fun.Polar(p13, pi / 2, (p16.Y - p13.Y) / 4.0);
            Vector2 v21_1 = fun.Polar(v21_, 0, oal + 5);
            Vector2 v13_1 = fun.Polar(p13, 0, dc_2 / 10);
            Vector2 v13_2 = fun.Polar(v13_1, fha_, oal + 5);
            Line line21 = new Line(v13_1, v13_2);
            Arc arc11 = fun.DrawArc5(p13, line21, p16);
            Vector2 p21 = fun.Inters1(v21_, v21_1, arc11, 1);
            Vector2 p22 = fun.Polar(p13, 0, sdl_2 + p15.X - p11.X);
            Vector2 v23 = fun.Polar(p11, 0, oal + 5);
            Vector2 v23_ = fun.Polar(p22, pi / 2, oal + 5);
            Vector2 p23 = fun.Inters(p11, v23, p22, v23_);
            Vector2 v13_3 = fun.Polar(p13, pi / -2, 0.01);
            Vector2 v13_4 = fun.Polar(v13_3, 0, oal + 5);
            Line line22 = new Line(v13_3, v13_4);
            Arc arc12 = fun.DrawArc5(p21, line22, p23);
            Line line23 = new Line(p22, p23);
            Arc arc13 = fun.DrawArc5(p19, line16, p14);
            Vector2 v24 = fun.Polar(p22, pi / 2, 0.001);
            Vector2 v24_ = fun.Polar(v24, pi, oal);
            Vector2 p24 = fun.Inters1(v24, v24_, arc12, 0);
            Line line24 = new Line(p22, p24);
            Vector2 p25 = fun.Polar(p22, sta_3_ / -2.0, Math.Sqrt(Math.Pow(((dc_3 - dc_2) / 2.0), 2) + (Math.Pow((sd_3 - sd_2 - sdl_2), 2))));
            Vector2 p26 = fun.mirrorpoint(p25, p0_1, p0_2);
            Line line25 = new Line(p22, p25);
            Line line26 = new Line(p20, p26);
            Vector2 v27 = fun.Polar(p25, pi / 2 - 20 * pi / 180, oal + 5);
            Vector2 p27 = fun.Inters(p0_1, p0_2, p25, v27);
            Vector2 v27_3 = fun.Polar(p27, 0, 0.1);
            Vector2 v27_4 = fun.Polar(v27_3, pi / -2 + 5 * pi / 180, oal + 5);
            Line line28 = new Line(v27_3, v27_4);
            Arc arc14 = fun.DrawArc5(p25, line28, p27);
            Line line29 = new Line(fun.Polar(p13, 0, dc_2 / 10), p16);
            Vector2 v23_1 = fun.Polar(p23, pi / -2, 0.01);
            Vector2 v23_2 = fun.Polar(v23_1, 0, oal);
            Line line30 = new Line(v23_1, v23_2);

            Vector2 p28 = fun.Polar(p27, 0, (lcf - sd_3) / 4.0);
            Vector2 v28_1 = fun.Polar(p28, 0, 0.1);
            Vector2 v28_2 = fun.Polar(v28_1, pi + fha_ * 1.5, oal);
            Line line31 = new Line(v28_1, v28_2);
            Arc arc19 = fun.DrawArc5(p25, line31, p28);
            Vector2 v29_1 = fun.Polar(p27, 0, (lcf - sd_3) / 4 * 3);
            Vector2 v29_2 = fun.Polar(v29_1, pi / 2, oal);
            Vector2 v29_3 = fun.Polar(fun.Polar(p26, pi / -2, dc_3 / 8), 0, oal);
            Vector2 p29 = fun.Inters(v29_1, v29_2, fun.Polar(p26, pi / -2, dc_3 / 8), v29_3);
            //Vector2 p29 = fun.PointRotate(p28, p25, pi);
            Arc arc20 = fun.DrawArc4(p29, arc19.Radius, p28, 0);
            Vector2 p30 = fun.Polar(p28, pi, (p28.X - p27.X) / 8.0);
            Vector2 v30_1 = fun.Polar(p25, 0, 0.1);
            Vector2 v30_2 = fun.Polar(p25, fha_ / 2, oal);
            Line line32 = new Line(v30_1, v30_2);
            Arc arc21 = fun.DrawArc5(p25, line32, p30);
            Arc arc22 = fun.DrawArc4(p29, arc21.Radius, p30, 0);
            Vector2 v31_1 = fun.Polar(p28, pi / 2 - 15 * pi / 180, oal);
            Vector2 v31_2 = fun.Polar(p26, 0, oal);
            Vector2 p31 = fun.Inters(p28, v31_1, p26, v31_2);
            Vector2 v31_3 = fun.Polar(p31, pi / 2, 0.1);
            Vector2 v31_4 = fun.Polar(v31_3, pi + 5 * pi / 180, oal);
            Line line33 = new Line(v31_3, v31_4);
            Arc arc23 = fun.DrawArc5(p31, line33, p27);
            Vector2 p32 = fun.Inters1(p26, fun.Polar(p26, -fha_ / 2, oal), arc23, 0);
            Vector2 v32_1 = fun.Polar(p26, pi / 2, 0.1);
            Vector2 v32_2 = fun.Polar(v32_1, -5 * pi / 180, oal);
            Line line34 = new Line(v32_2, v32_1);
            Arc arc24 = fun.DrawArc5(p32, line34, p26);
            Vector2 p33 = fun.Inters1(fun.Polar(p31, pi / -2, 0.299), fun.Polar(fun.Polar(p31, pi / -2, 0.299), 0, oal), arc22, 0);
            Line line35 = new Line(p31, p33);
            Vector2 v34 = fun.Polar(p25, pi / 2, dc_3 / 2.0 / 4.0);
            Vector2 v34_ = fun.Polar(v34, 0, oal);
            Vector2 p34 = fun.Inters1(v34, v34_, arc19, 1);
            Vector2 p35 = fun.Inters(p0_1, p0_2, p33, fun.Polar(p33, pi / -2, oal));
            Vector2 v35_1 = fun.Polar(p25, pi / 2, 1);
            Vector2 v35_2 = fun.Polar(v35_1, 0, oal);
            Line line36 = new Line(v35_1, v35_2);
            Arc arc25 = fun.DrawArc5(p34, line36, p35);
            Vector2 v36 = fun.Polar(p35, fha_, oal);
            Vector2 v36_1 = fun.Polar(p33, 0, oal);
            Vector2 p36 = fun.Inters(p35, v36, p33, v36_1);
            Arc arc26 = fun.DrawArc3(p36, p29, p35);
            Vector2 p37 = fun.Polar(p26, 0, oal - ls - sd_3);
            Vector2 p38 = fun.mirrorpoint(p37, p0_1, p0_2);
            Vector2 p39 = fun.Polar(p37, pi, (oal - ls - sd_3) / 25.0);
            Line line37 = new Line(p36, p37);
            Line line38 = new Line(p37, p38);
            Vector2 v40_1 = fun.Polar(p25, pi / 2, 1.01);
            Vector2 v40_2 = fun.Polar(v40_1, 0, oal);
            Vector2 p40 = fun.Inters1(v40_1, v40_2, arc25, 1);
            Vector2 v41 = fun.Polar(p29, pi / -2 - pi / 6, oal);
            Vector2 v41_ = fun.Polar(p40, 0, oal);
            Vector2 p41 = fun.Inters(p40, v41_, p29, v41);
            Line line39 = new Line(p40, p41);
            Vector2 v41_1 = fun.Polar(p41, 0, (oal - ls - sd_3) / 20.0);
            Vector2 v41_2 = fun.Polar(v41_1, fha_ * 1.5, oal);
            Line line40 = new Line(v41_1, v41_2);
            Arc arc27 = fun.DrawArc5(p41, line40, p39);
            Vector2 v42_1 = fun.Polar(p38, pi, oal);
            Vector2 v42_2 = fun.Polar(p39, pi / -2 - 11 * pi / 180, oal);
            Vector2 p42 = fun.Inters(p38, v42_1, p39, v42_2);
            Vector2 v43 = fun.Polar(p41, fha_ * 1.1, oal);
            Vector2 p43 = fun.Inters(p41, v43, p0_1, p0_2);
            Vector2 v43_1 = fun.Polar(v41_1, fha_ * 1.25, oal);
            Line line41 = new Line(v41_1, v43_1);
            Line line42 = new Line(p38, p42);
            Arc arc28 = fun.DrawArc5(p41, line41, p43);
            Vector2 p44 = fun.Polar(p43, -35 * pi / 180, 9.76 / 2.0 / 24.0 * dc_3);
            Vector2 v45 = fun.Polar(p34, 0, oal);
            Vector2 p45 = fun.Inters1(p34, v45, arc28, 1);
            Vector2 p46 = fun.Polar(p44, 0 * pi / 180, 5.0342 / 24.0 * dc_3);
            Vector2 v45_1 = fun.Polar(p42, pi / -2, 0.01);
            Vector2 v45_2 = fun.Polar(v45_1, pi, oal);
            Line line44 = new Line(v45_1, v45_2);
            Arc arc29 = fun.DrawArc5(p45, line44, p42);
            /* Ellipse ellipse00 = new Ellipse(p44, 10.8/24*dc_3 , 9.76 / 24 * dc_3 );//椭圆
             ellipse00.Rotation = 55;
             ellipse00.EndAngle = 90;
             ellipse00.StartAngle = -55;
             ellipse00.Layer = contour;
             ellipse00.Lineweight = Lineweight.W50;
             dxf.AddEntity(ellipse00);
             */
            var polyline6 = Pus.AddPointsToLwPolyLine(p43, p46);
            polyline6.Vertexes[0].Bulge = Math.Tan(146 * pi / 180);
            Vector2 v46_1 = fun.Polar(p42, 0, (oal - ls - sd_3) / 20.0 / 2.0);
            Vector2 v46_2 = fun.Polar(v46_1, fha_ * 3.0, oal);
            Line line43 = new Line(v46_1, v46_2);
            Arc arc30 = fun.DrawArc5(p42, line43, p46);
            Vector2 p47 = fun.Polar(p37, 0, ls - 1 / 64 * ls);
            Vector2 p48 = fun.mirrorpoint(p47, p0_1, p0_2);
            Vector2 p49 = fun.Polar(p47, pi / -4, Math.Sqrt(2) / 64 * ls);
            Vector2 p50 = fun.mirrorpoint(p49, p0_1, p0_2);
            var polyline2 = Pus.AddPointsToLwPolyLine(p37, p47, p49, p50, p48, p47, p48, p38); ;

            for (double i = 0; i < 2; i++)
            {
                Vector2 i0 = new Vector2(-oal * 1.5, 0);
                Vector2 i0_1 = fun.Polar(i0, 0, sd_2 * 10 + 5);
                Vector2 i0_2 = fun.Polar(i0, pi, 5);
                Vector2 i1 = fun.Polar(i0, sig_ / 2.0, (Math.Sqrt(Math.Pow(dc_1 / 2.0, 2) + Math.Pow(pl, 2))) * 5);
                Vector2 i2 = fun.mirrorpoint(i1, i0_1, i0_2);
                Vector2 u1 = fun.Polar(i0, -10 * pi / 180, oal);
                Vector2 u1_ = fun.Polar(i2, pi / 2, oal);
                Vector2 i3 = fun.Inters(i0, u1, i2, u1_);
                Vector2 u1_1 = fun.Polar(i1, pi / 2, 0.0001 * 5);
                Vector2 u1_2 = new Vector2(u1_1.X + oal + 5, u1_1.Y);
                Line line45 = new Line(u1_1, u1_2);
                Vector2 u5 = fun.Polar(i2, fha_, oal * 5);
                Vector2 u5_1 = fun.Polar(i2, 0, dc_1 / 10 * 5);
                Vector2 u5_2 = fun.Polar(u5_1, fha_, (oal + 5) * 5);
                Line line46 = new Line(u5_2, u5_1);
                Vector2 i5 = fun.Inters(i2, u5, i0_1, i0_2);
                //Vector2 p5 = fun.Polar(p0, 0, p1.X + sdl_1 / 2.0);
                Line line47 = new Line(fun.Polar(i2, 0, (dc_1 / 10) * 5), i5);
                Vector2 i6 = fun.Polar(i5, pi, dc_1 / 10 * 5);
                Vector2 u7 = fun.Polar(i5, pi / 2 + 15 * pi / 180, oal * 5);
                Vector2 i7 = fun.Inters(i5, u7, u1_1, u1_2);
                Vector2 u7_1 = fun.Polar(i7, pi, dc_1 / 10 * 5);
                Vector2 u7_2 = fun.Polar(u7_1, pi + fha_, oal * 5);
                Line line48 = new Line(u7_1, u7_2);
                Arc arc4_ = fun.DrawArc5(i7, line48, i3);
                Vector2 i4 = fun.Inters1(i1, fun.Polar(i1, -fha_ / 2, oal * 5), arc4_, 0);
                Vector2 i8 = fun.PointRotate(i5, i2, pi);
                Vector2 u8_1 = fun.Polar(i8, pi, dc_1 / 10 * 5);
                Vector2 u8_2 = fun.Polar(u8_1, pi + fha_, (oal + 5) * 5);
                Line line49 = new Line(u8_1, u8_2);
                Line line50 = new Line(i8, i6);
                Line line51 = new Line(i7, i8);
                Vector2 u9_ = fun.Polar(i2, pi / 2, (i5.Y - i2.Y) / 3.0);
                Vector2 u9_1 = fun.Polar(u9_, 0, (oal + 5) * 5);
                Arc arc2_ = fun.DrawArc5(i2, line46, i5);
                Vector2 i9 = fun.Inters1(u9_, u9_1, arc2_, 1);
                Vector2 i10 = fun.Polar(i2, 0, (sdl_1 + p1.X / 2.0) * 5);
                Vector2 u11 = fun.Polar(i3, 0, oal + 5);
                Vector2 u11_ = fun.Polar(i10, pi / 2, oal + 5);
                Vector2 i11 = fun.Inters(i3, u11, i10, u11_);
                Vector2 u2_1 = fun.Polar(i2, pi / -2, 0.001 * 5);
                Vector2 u2_2 = new Vector2(u2_1.X + oal + 5, u2_1.Y);
                Line line52 = new Line(u2_1, u2_2);
                Arc arc7_ = fun.DrawArc5(i9, line52, i11);
                Line line53 = new Line(i10, i11);
                var polyline5 = Pus.AddPointsToLwPolyLine(i1, i0, i2, i3, i0);
                Arc arc1_ = fun.DrawArc5(i4, line45, i1);
                Vector2 u12 = fun.Polar(i10, pi / 2, 0.001 * 5);
                Vector2 u12_ = fun.Polar(u12, pi, oal);
                Vector2 i12 = fun.Inters1(u12, u12_, arc7_, 0);
                Line line54 = new Line(i10, i12);
                Vector2 i13 = fun.Polar(i10, sta_2_ / -2.0, Math.Sqrt(Math.Pow(((dc_2 - dc_1) / 2.0), 2) + (Math.Pow((sd_2 - sdl_1 - pl), 2))) * 5);
                Vector2 i14 = fun.mirrorpoint(i13, i0_1, i0_2);
                Line line55 = new Line(i10, i13);
                Line line56 = new Line(i8, i14);
                Vector2 u15 = fun.Polar(i13, pi / 2 - 10 * pi / 180, oal + 5);
                Vector2 u15_1 = fun.Polar(i11, pi / -2, 0.1 * 5);
                Vector2 u15_2 = new Vector2(u15_1.X + oal + 5, v15_1.Y);
                Line line57 = new Line(u15_1, u15_2);
                Vector2 i15 = fun.Inters(i0_1, i0_2, i13, u15);
                Vector2 u15_3 = fun.Polar(i15, 0, dc_2 / 10.0);
                Vector2 u15_4 = fun.Polar(u15_3, pi / -2 - 10 * pi / 180, oal + 5);
                Line line58 = new Line(u15_3, u15_4);

                Vector2 u16 = fun.Polar(i13, fha_, oal + 5);
                Vector2 u16_1 = fun.Polar(i13, 0, dc_1 / 10 * 5);
                Vector2 u16_2 = fun.Polar(u16_1, fha_, oal + 5);
                Line line15_ = new Line(u16_1, u16_2);
                Vector2 i16 = fun.Inters(i13, u16, i0_1, i0_2);
                Vector2 i17 = fun.Polar(i16, pi, dc_2 / 10 * 5);
                Vector2 u18 = fun.Polar(i16, pi / 2 + 15 * pi / 180, oal);
                Vector2 u14_1 = fun.Polar(i14, pi / 2, 0.01 * 5);
                Vector2 u14_2 = fun.Polar(u14_1, 0, oal + 5);
                Line line16_ = new Line(u14_1, u14_2);
                Vector2 i18 = fun.Inters(i16, u18, u14_1, u14_2);
                Vector2 u18_1 = fun.Polar(i18, pi, dc_2 / 10 * 5);
                Vector2 u18_2 = fun.Polar(u18_1, pi + fha_, oal);
                Line line17_ = new Line(u18_1, u18_2);
                Arc arc10_ = fun.DrawArc5(i18, line17_, i15);
                Vector2 i19 = fun.Inters1(i14, fun.Polar(i14, -fha_ / 2, oal), arc10_, 0);
                Vector2 i20 = fun.PointRotate(i16, i13, pi);
                Vector2 u20_1 = fun.Polar(i20, pi, dc_2 / 10 * 5);
                Vector2 u20_2 = fun.Polar(u20_1, pi + fha_, oal + 5);
                Line line18_ = new Line(u20_1, u20_2);
                Line line19_ = new Line(i19, i17);
                Line line20_ = new Line(i18, i20);
                Vector2 u21_ = fun.Polar(i13, pi / 2, (i16.Y - i13.Y) / 4.0);
                Vector2 u21_1 = fun.Polar(u21_, 0, oal + 5);
                Vector2 u13_1 = fun.Polar(i13, 0, dc_2 / 10 * 5);
                Vector2 u13_2 = fun.Polar(u13_1, fha_, oal + 5);
                Line line21_ = new Line(u13_1, u13_2);
                Arc arc11_ = fun.DrawArc5(i13, line21_, i16);
                Vector2 i21 = fun.Inters1(u21_, u21_1, arc11_, 1);
                Vector2 i22 = fun.Polar(i13, 0, sdl_2 * 5 + p15.X - p11.X);
                Vector2 u23 = fun.Polar(i11, 0, oal + 5);
                Vector2 u23_ = fun.Polar(i22, pi / 2, oal + 5);
                Vector2 i23 = fun.Inters(i11, u23, i22, u23_);
                Vector2 u13_3 = fun.Polar(i13, pi / -2, 0.01 * 5);
                Vector2 u13_4 = fun.Polar(u13_3, 0, oal + 5);
                Line line22_ = new Line(u13_3, u13_4);
                Arc arc12_ = fun.DrawArc5(i21, line22_, i23);
                Line line23_ = new Line(i22, i23);
                Arc arc13_ = fun.DrawArc5(i19, line16_, i14);
                Vector2 u24 = fun.Polar(i22, pi / 2, 0.001 * 5);
                Vector2 u24_ = fun.Polar(u24, pi, oal);
                Vector2 i24 = fun.Inters1(u24, u24_, arc12_, 0);
                Arc arc12_1 = fun.DrawArc4(i21, arc12_.Radius, i24, 0);
                Line line29_ = new Line(fun.Polar(i13, 0, dc_2 / 10 * 5), i16);



                Arc arc3_ = fun.DrawArc5(i2, line47, i6);
                Arc arc5_ = fun.DrawArc4(i8, arc3_.Radius, i6, 0);
                Arc arc6_ = fun.DrawArc4(i8, arc2_.Radius, i5, 0);
                Arc arc8_ = fun.DrawArc5(i11, line57, i15);
                Arc arc9_ = fun.DrawArc5(i13, line58, i15);
                Arc arc15_ = fun.DrawArc5(i13, line29_, i17);
                // Line line100 = new Line(i9, fun.Polar(i9, pi / 2, 100));
                fun.PolyFill(dxf, polyline5, 0.5, contour);
                fun.drawBArc(dxf, arc1_, 0.5, contour);
                fun.drawBArc(dxf, arc2_, 0.5, contour);
                fun.drawBArc(dxf, arc3_, 0.5, contour);
                fun.drawBArc(dxf, arc4_, 0.5, contour);
                fun.drawBArc(dxf, arc5_, 0.5, contour);
                fun.drawBArc(dxf, arc6_, 0.5, contour);
                fun.drawBArc(dxf, arc7_, 0.5, contour);
                fun.drawBArc(dxf, arc8_, 0.5, contour);
                fun.drawBArc(dxf, arc9_, 0.5, contour);
                fun.drawBArc(dxf, arc10_, 0.5, contour);
                fun.drawBArc(dxf, arc11_, 0.5, contour);
                fun.drawBArc(dxf, arc12_1, 0.5, contour);
                fun.drawBArc(dxf, arc13_, 0.5, contour);
                fun.drawBArc(dxf, arc15_, 0.5, contour);
                fun.drawBline(dxf, line51, 0.5, contour);
                fun.drawBline(dxf, line53, 0.5, contour);
                fun.drawBline(dxf, line54, 0.5, contour);
                fun.drawBline(dxf, line55, 0.5, contour);
                fun.drawBline(dxf, line56, 0.5, contour);

                //标注
                Vector2 q1 = fun.Polar(i8, pi / 2, dc_1 * 5 + 15);
                Vector2 q2 = fun.Polar(p37, 0, fun.CalDistance(p47, p37) / 2.0);
                Vector2 q3 = fun.Polar(q2, pi / -2, fun.CalDistance(p48, p47) / 2.0);

                Vector2 q4 = fun.Polar(p0, pi, dconms + dconms);
                Vector2 q5 = fun.Polar(q4, pi / 2, dc_3 * 5);

                Vector2 q6 = fun.Polar(p49, pi / -2, fun.CalDistance(p49, p50) / 2.0);
                Vector2 q7 = fun.Polar(q6, pi / -4, 1.7);
                Vector2 q8 = fun.Polar(q7, pi / -4, dconms * 2);
                Vector2 q9 = fun.Polar(q8, pi / -2, 1.2 * 5);
                Vector2 q10 = fun.Polar(q3, pi + pi / 6, 1.7);
                Vector2 q11 = fun.Polar(q10, pi + pi / 6, dconms * 3);
                Vector2 q12 = fun.Polar(q11, pi / -2, 1.2 * 5);
                Vector2 q13 = fun.Polar(i0, pi + pi / 3, 1.7);
                Vector2 q14 = fun.Polar(q13, pi + pi / 3, dconms * 2);
                Vector2 q15 = fun.Polar(q14, pi / -2, 1.2 * 5);
                Vector2 q19 = fun.Polar(p1, pi / 2, dc_1);
                Line line100 = new Line(p0_1, p0_2);
                line100.Lineweight = Lineweight.W25;//Lineweight指线宽
                line100.Layer = additionalline;//Layer指图层
                line100.LinetypeScale = 5;//指线性比例
                line100.Linetype = Linetype.DashDot;//Linetype指是点划线还是虚线什么的
                dxf.AddEntity(line100); //提取
                Vector2 q16_ = fun.Polar(q3, pi / 2, dconms);
                Vector2 q17_ = fun.Polar(q16_, pi / 4, dconms / 4.0);
                Vector2 q18_ = fun.Polar(q17_, 0, dconms / 2.0);
                Vector2 q19_ = fun.mirrorpoint(q16_, p0_1, p0_2);
                Vector2 q20_ = fun.mirrorpoint(q17_, p0_1, p0_2);
                Vector2 q21_ = fun.mirrorpoint(q18_, p0_1, p0_2);
                Line linev1 = new Line(q16_, q19_);
                Line linev2 = new Line(q16_, q17_);
                Line linev3 = new Line(q17_, q18_);
                Line linev4 = new Line(q19_, q20_);
                Line linev5 = new Line(q20_, q21_);
                Line linev6 = new Line(i0_1, i0_2);
                linev1.Layer = additionalline;//Layer指图层
                linev1.Linetype = Linetype.DashDot;//Linetype指是点划线还是虚线什么的
                linev1.LinetypeScale = 5;//指线性比例
                linev2.Layer = additionalline;//Layer指图层
                linev2.Linetype = Linetype.DashDot;//Linetype指是点划线还是虚线什么的
                linev2.LinetypeScale = 5;//指线性比例
                linev3.Layer = additionalline;//Layer指图层
                linev3.Linetype = Linetype.DashDot;//Linetype指是点划线还是虚线什么的
                linev3.LinetypeScale = 5;//指线性比例
                linev4.Layer = additionalline;//Layer指图层
                linev4.Linetype = Linetype.DashDot;//Linetype指是点划线还是虚线什么的
                linev4.LinetypeScale = 5;//指线性比例
                linev5.Layer = additionalline;//Layer指图层
                linev5.Linetype = Linetype.DashDot;//Linetype指是点划线还是虚线什么的
                linev5.LinetypeScale = 5;//指线性比例
                linev6.Lineweight = Lineweight.W25;//Lineweight指线宽
                linev6.Layer = center;//Layer指图层
                linev6.LinetypeScale = 5;//指线性比例
                linev6.Linetype = Linetype.DashDot;//Linetype指是点划线还是虚线什么的
                dxf.AddEntity(linev6); //提取

                dxf.AddEntity(new EntityObject[] { linev1, linev2, linev3, linev4, linev5 });
                //fun.dimrot1(dxf, i0, i14, 0, dc_1 * 5, 2, 1.2 * 5, 1.6 * 5, 0.9, "SD_2", "", "");
                fun.dimrot1(dxf, i1, i8, 0, dc_1 * 5 / 2.0, 2, 1.2 * 5, 1.6 * 5, 0.9, "SDL", "", "");
                // fun.dimrot1(dxf, i0, i2, 180, dc_1 * 5 / 2.0, 2, 1.2 * 5, 1.6 * 5, 0.9, "PL", "", "");
                fun.dimrot1(dxf, fun.Polar(i2, pi, 0.001), i2, 180, dc_1 * 5 / 1.7, 2, 1.2 * 5, 1.6 * 5, 0.9, "PL", "", "");
                // fun.dimrot1(dxf, i13, i14, -90, dc_1 * 20, 2, 1.2 * 5, 1.6 * 5, 0.9, "DC_2", "", "");
                fun.dimrot1(dxf, i1, i2, 90, dc_1 * 5, 2, 1.2 * 5, 1.6 * 5, 0.9, "DC", "", "");

                fun.dimrot1(dxf, p49, p0, 0, dc_3 * 7, 2, 1.2 * 5, 1.6 * 5, 0.9, "OAL", "", "");
                fun.dimrot1(dxf, q2, p0, 0, dc_3 * 6, 2, 1.2 * 5, 1.6 * 5, 0.9, "LPR", "", "");
                //fun.dimrot1(dxf, q2, p1, 0, dc_3 * 5, 2, 1.2 * 5, 1.6 * 5, 0.9, "LTA", "", "");
                fun.dimrot1(dxf, p46, p0, 0, dc_3 * 4, 2, 1.2 * 5, 1.6 * 5, 0.9, "LCF", "", "");
                fun.dimrot1(dxf, fun.Polar(p36, 0, fun.CalDistance(p36, p39) / 2.0), p0, 0, dc_3 * 3, 2, 1.2 * 5, 1.6 * 5, 0.9, "LU", "", "");
                // fun.dimrot1(dxf, fun.Polar(p36, 0, fun.CalDistance(p36, p39) / 2.0), p26, 0, dc_3 * 2, 2, 1.2 * 5, 1.6 * 5, 0.9, "SDL_3", "", "");
                // fun.dimrot1(dxf, p20, p14, 0, dc_3 * 2 + (p26.Y - p20.Y), 2, 1.2 * 5, 1.6 * 5, 0.9, "SDL_2", "", "");
                fun.dimrot1(dxf, p50, p38, 180, dc_3 * 2, 2, 1.2 * 5, 1.6 * 5, 0.9, "LS", "", "");
                fun.dimrot1(dxf, p26, p0, 0, dc_3 * 2 + (p26.Y - p20.Y) + (p14.Y / 2.0), 2, 1.2 * 5, 1.6 * 5, 0.9, "SD", "", "a");
                //fun.dimrot1(dxf, p50, p2, 180, dc_3 * 3, 2, 1.2 * 5, 1.6 * 5, 0.9, "LF", "", "");
                fun.dimrot1(dxf, p48, p47, -90, dc_3 * 2, 2, 1.2 * 5, 1.6 * 5, 0.9, "DMM", "", "");
                fun.dimrot1(dxf, p25, p26, 90, sd_3 * 1.5, 2, 1.2 * 5, 1.6 * 5, 0.9, "DC", "", "");
                //fun.dimrot1(dxf, p14, p0, 0, dc_3 * 2 + (p26.Y - p20.Y) + (p14.Y / 2.0), 2, 1.2 * 5, 1.6 * 5, 0.9, "SD_2", "", "");

                fun.jdbz2(dxf, new Line(i0, fun.Polar(i0, pi - sig_ / 2, 0.1)), new Line(i0, fun.Polar(i0, pi + sig_ / 2, 0.1)), dc_1 * 5, 1.2 * 5, 1.6 * 5, 0.9, "SIG", "", "0");
                //fun.jdbz2(dxf, new Line(i10, i13), new Line(i8, i14), dc_1 * 15 * 1.5, 1.2 * 5, 1.6 * 5, 0.9, "STA_2", "", "");
                fun.jdbz2(dxf, new Line(p22, p25), new Line(p20, p26), dc_1 * 5, 1.2 * 5, 1.6 * 5, 0.9, "STA", "", "");
                /*
                fun.Axis(dxf, fun.Polar(p50, pi / -2, dc_3 * 4), 0, -90, "Z", "X", "Y", 1.0, 1.2 * 5, 1);
                fun.Axis(dxf, q6, 0, -90, "", "", "", 1.0, 1.2 * 5, 1);
                fun.Axis(dxf, q3, 0, -90, "", "", "", 1.0, 1.2 * 5, 1);
                fun.Axis(dxf, i0, 0, -90, "", "", "", 1.0, 1.2 * 5, 1);
                */
                Line lineq1 = new Line(q7, q8);
                Line lineq2 = new Line(q10, q11);
                Line lineq3 = new Line(q13, q14);
                Line lineq6 = new Line(q19, fun.Polar(q19, pi / 4, dc_1));
                Text txt1 = new Text("X_X", q1, 1.2 * 5, 2);
                Text txt3 = new Text("X", fun.Polar(q19, pi / 4, dc_1), 1.2 * 5, 2);
                dxf.AddEntity(new EntityObject[] { txt1, txt3, lineq6 });
                Text txt2 = new Text("ISYC=302_02", fun.Polar(p0, pi / 2, dc_3 * 8), 1.2 * 5, 2);

                Text txt4 = new Text("MCS", q12, 1.2 * 5, 2);
                Text txt5 = new Text("CIP", q15, 1.2 * 5, 2);
                //dxf.AddEntity(new EntityObject[] { lineq1, lineq2, lineq3, txt1, txt2, txt3, txt4, txt5 });
                Vector2 q16 = fun.Polar(i2, pi / -2, dc_1 * 5 / 1.7 / 1.5);
                Vector2 q17 = fun.Polar(i1, pi / 2, dc_1 * 10 / 2.0);
                Vector2 q18 = fun.Polar(i1, pi / 2, dc_1 * 10 / 1.5);
                Line lineq4 = new Line(i1, fun.Polar(i1, pi / 2, dc_1 * 10 / 1.2));
                dxf.AddEntity(lineq4);
                //fun.Singlelinearrow(dxf, "CCMS", q2, 45, fun.Polar(q2, pi / 4, dconms / 2.0), fun.Polar(q2, pi / 4, dconms), 1.2 * 5, 1.6 * 5);
                // fun.Singlelinearrow(dxf, "FDP", q5, 180, fun.Polar(q5, 0, dconms / 2.0), fun.Polar(q5, 0, dconms), 1.2 * 5, 1.6 * 5);
                fun.Singlelinearrow(dxf, "LF", q16, 180, fun.Polar(q16, 0, dconms / 2.0), fun.Polar(q16, 0, dconms), 1.2 * 5, 1.6 * 5);
                fun.Singlelinearrow(dxf, "SD", q17, 180, fun.Polar(q17, 0, dconms / 2.0), fun.Polar(q17, 0, dconms), 1.2 * 5, 1.6 * 5);
                fun.Singlelinearrow(dxf, "LU", q18, 180, fun.Polar(q18, 0, dconms / 2.0), fun.Polar(q18, 0, dconms), 1.2 * 5, 1.6 * 5);
                Ellipse ellipse01 = new Ellipse(fun.Polar(p8, pi / -2, dc_1 / 2.0), dc_3 * 2.5, dc_1 * 4);//椭圆               
                ellipse01.Rotation = 0;
                ellipse01.EndAngle = 90;
                ellipse01.StartAngle = 90;
                ellipse01.Layer = additionalline;
                ellipse01.Linetype = Linetype.DashDot;
                ellipse01.LinetypeScale = 5;
                ellipse01.Lineweight = Lineweight.W50;
                dxf.AddEntity(ellipse01);
            }
            Arc arc3 = fun.DrawArc5(p2, line3, p6);
            Arc arc5 = fun.DrawArc4(p8, arc3.Radius, p6, 0);
            Arc arc6 = fun.DrawArc4(p8, arc2.Radius, p5, 0);
            Arc arc8 = fun.DrawArc5(p11, line13, p15);
            Arc arc9 = fun.DrawArc5(p13, line14, p15);
            Arc arc15 = fun.DrawArc5(p13, line29, p17);
            Arc arc16 = fun.DrawArc4(p20, arc11.Radius, p16, 0);
            Arc arc17 = fun.DrawArc4(p20, arc15.Radius, p17, 0);
            Arc arc18 = fun.DrawArc5(p23, line30, p27);

            fun.drawBArc(dxf, arc1, 0.5, contour);
            fun.drawBArc(dxf, arc2, 0.5, contour);
            fun.drawBArc(dxf, arc3, 0.5, contour);
            fun.drawBArc(dxf, arc4, 0.5, contour);
            fun.drawBArc(dxf, arc5, 0.5, contour);
            fun.drawBArc(dxf, arc6, 0.5, contour);
            fun.drawBArc(dxf, arc7, 0.5, contour);
            fun.drawBArc(dxf, arc8, 0.5, contour);
            fun.drawBArc(dxf, arc9, 0.5, contour);
            fun.drawBArc(dxf, arc10, 0.5, contour);
            fun.drawBArc(dxf, arc11, 0.5, contour);
            fun.drawBArc(dxf, arc12, 0.5, contour);
            fun.drawBArc(dxf, arc13, 0.5, contour);
            fun.drawBArc(dxf, arc14, 0.5, contour);
            fun.drawBArc(dxf, arc15, 0.5, contour);
            fun.drawBArc(dxf, arc16, 0.5, contour);
            fun.drawBArc(dxf, arc17, 0.5, contour);
            fun.drawBArc(dxf, arc18, 0.5, contour);
            fun.drawBArc(dxf, arc19, 0.5, contour);
            fun.drawBArc(dxf, arc20, 0.5, contour);
            fun.drawBArc(dxf, arc21, 0.5, contour);
            fun.drawBArc(dxf, arc22, 0.5, contour);
            fun.drawBArc(dxf, arc23, 0.5, contour);
            fun.drawBArc(dxf, arc24, 0.5, contour);
            fun.drawBArc(dxf, arc25, 0.5, contour);
            fun.drawBArc(dxf, arc26, 0.5, contour);
            fun.drawBArc(dxf, arc27, 0.5, contour);
            fun.drawBArc(dxf, arc28, 0.5, contour);
            fun.drawBArc(dxf, arc29, 0.5, contour);
            fun.drawBArc(dxf, arc30, 0.5, contour);

            fun.PolyFill(dxf, polyline2, 0.5, contour);
            fun.PolyFill(dxf, polyline4, 0.5, contour);
            fun.PolyFill(dxf, polyline6, 0.5, contour);

            fun.drawBline(dxf, line7, 0.5, contour);
            fun.drawBline(dxf, line9, 0.5, contour);
            fun.drawBline(dxf, line10, 0.5, contour);
            fun.drawBline(dxf, line11, 0.5, contour);
            fun.drawBline(dxf, line12, 0.5, contour);
            fun.drawBline(dxf, line20, 0.5, contour);
            fun.drawBline(dxf, line23, 0.5, contour);
            fun.drawBline(dxf, line24, 0.5, contour);
            fun.drawBline(dxf, line25, 0.5, contour);
            fun.drawBline(dxf, line26, 0.5, contour);
            fun.drawBline(dxf, line35, 0.5, contour);
            fun.drawBline(dxf, line37, 0.5, contour);
            fun.drawBline(dxf, line38, 0.5, contour);
            fun.drawBline(dxf, line39, 0.5, contour);
            fun.drawBline(dxf, line42, 0.5, contour);

            double isframe = Convert.ToInt32(data["isframe"]);
            String isframe_chose = Convert.ToString(data["isframe_chose"]);
            double scale = Convert.ToDouble(data["scale"]); //放大系数
            if (isframe == 1)
            {
                if (isframe_chose.Equals("0"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA0X(dxf, new Vector2(p0.X - 1189 / 2.0, p0.Y + 841 / 2.0), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }

                if (isframe_chose.Equals("1"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA1X(dxf, new Vector2(p0.X - 841 / 2.0, p0.Y + 594 / 2.0), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }

                if (isframe_chose.Equals("2"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA2X(dxf, new Vector2(p0.X - 594 / 2.0, p0.Y + 420 / 2.0), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }

                if (isframe_chose.Equals("3"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA3X(dxf, new Vector2(p0.X - 420 / 2.0, p0.Y + 297 / 2.0), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }

                if (isframe_chose.Equals("4X"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA4X(dxf, new Vector2(p0.X - 297 / 2.0, p0.Y + 210 / 2.0 - 10 * 2.26), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }

                if (isframe_chose.Equals("4Y"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA4Y(dxf, new Vector2(p0.X - 210 / 2.0, p0.Y + 297 / 2.0), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }
            }






            fun.SetLayer(dxf);
            fun.SetByLayer(dxf);

            dxf.DrawingVariables.AcadVer = DxfVersion.AutoCad2007;
            dxf.Save(path);
        }

        public static void ThreadCutting(Dictionary<string, Object> data)  //圆板牙
        {
            DxfDocument dxf = new DxfDocument();
            dxf.Layers["0"].Lineweight = Lineweight.W25;
            Layer contour = new Layer("contour");//轮廓层
            Layer dimensioning = new Layer("dimensioning");//尺寸层
            Layer refin = new Layer("refin");//基准线/内轮廓/虚线
            Layer center = new Layer("center");//中心线
            Layer textlayer = new Layer("textlayer");//文本层
            Layer hatching = new Layer("hatching");//填充层
            Layer additionalline = new Layer("additionalline");//附加线
            Layer cutting = new Layer("cutting");//切削层
            fun.SetLayer(dxf);

            double pi = Math.PI;
            string path = Convert.ToString(data["path"]);

            /*
            double d =1;
            double P = 0.25;
            double d1 = d - (P * 1.0825);//小径
            double b = 3;
            double D = 16;
            double D1;
            double DD1 = 0;
            double E = 5;
            double E1 = 2;
            double c = 0.5;
            double a = 0.2;
            double pxk = 4;//排泄孔
            double px = pi - pi / 4 / 4;
            */
            /*
            double d = 7.0;
            double P = 1.0;
            double d1 = d - (P * 1.0825);//小径
            double b = 5.0;
            double D = 30;
            double D1 = 24;
            double DD1 = 0;
            double E = 8.0;
            double E1 = 0;
            double c = 0.8;
            double a = 0.5;
            double pxk = 6;//排泄孔
            double px = pi - pi /4/4;
            */

            double scale = Convert.ToDouble(data["scale"]); //放大系数
            double d = Convert.ToDouble(data["td"])* scale;
            double P = Convert.ToDouble(data["tp"]) * scale;
            double d1 = d - (P * 1.0825);//小径
            double b = Convert.ToDouble(data["b"]) * scale;
            double D = Convert.ToDouble(data["bd"]) * scale;
            double D1 = Convert.ToDouble(data["d1"]) * scale;
            double DD1 = Convert.ToDouble(data["dd1"]) * scale;
            double E = Convert.ToDouble(data["oal"]) * scale;
            double E1 = Convert.ToDouble(data["e1"]) * scale;
            double c = Convert.ToDouble(data["c"]) * scale;
            double a = Convert.ToDouble(data["a"]) * scale;
            double pxk = Convert.ToDouble(data["pxk"]) * scale;//排泄孔
            double px = pi - pi / 4 / 4;
            double pd = d % 1;
            double pd1 = (pd * 10.0) % 1;
            /*
            double d = 7.723;
            double P = 0.907;
            double d1 = d - (P * 1.0825);//小径
            double b = 5;
            double D = 25;
            double D1 = 0;
            double DD1 = 0;
            double E = 7.0;
            double E1 = 0;
            double c = 0.8;
            double a = 0.5;
            double pxk = 6;//排泄孔
            double px = pi - pi / 4 / 4;            
            double pd = d % 1;
            double pd1 = (pd * 10.0)%1;
            */
            if (pxk == 0)
            {
                pxk = DD1 / 2 - d1 / 2.0 + 0.01;

            }

            if (D >= 25 && pd1 != 0)
            {
                px = pi / 2 + pi / 4 / 4;

            }
            else
            {
                px = pi - pi / 4 / 4;
            }



            if (D >= 25 * scale && pd1 != 0)
            {
                E1 = E;
                D1 = D - b;
                DD1 = D1;
            }


            else if (D >= 25 * scale && E1 == 0)
            {

                E1 = 8 / 9.0 * E;
                D1 = D * (22.5 / 25);
                DD1 = D1 - (D - D1);
            }

            else if (D == 20 * scale && E1 == 0)
            {
                E1 = E;
                D1 = D * (15 / 20.0);
                DD1 = D1;
            }
            else
            {
                //  E1 = Convert.ToDouble(data["e1"]);
                //  D1 = Convert.ToDouble(data["d1"]);

                D1 = 22.5;
                E1 = 8;
                //E1=5
                DD1 = D1 - (D - D1);
            }
            double ang1 = Math.Acos(((d1 / 2.0 * d1 / 2.0) + ((d1 / 2 - 0.1 + pxk / 2.0) * (d1 / 2 - 0.1 + pxk / 2.0)) - (pxk / 2.0 * pxk / 2.0)) / (2 * d1 / 2.0 * (d1 / 2 - 0.1 + pxk / 2.0)));

            double ang2 = Math.Acos(((d / 2.0 * d / 2.0) + ((d1 / 2 - 0.1 + pxk / 2.0) * (d1 / 2 - 0.1 + pxk / 2.0)) - (pxk / 2.0 * pxk / 2.0)) / (2 * d / 2.0 * (d1 / 2 - 0.1 + pxk / 2.0)));
            System.Diagnostics.Debug.WriteLine(E);
            System.Diagnostics.Debug.WriteLine(E1);
            System.Diagnostics.Debug.WriteLine(pd);
            if (D < 25 * scale)
            {


                Vector2 p0 = new Vector2(0, 0);
                Vector2 zx1 = new Vector2(0, -D / 2 - 4);
                Vector2 zx2 = new Vector2(0, D / 2 + 4);
                Vector2 p1p = fun.Polar(p0, pi / 2, d1 / 2 - 0.1 + pxk / 2.0);
                Vector2 p2p = fun.PointRotate(p0, p1p, pi * 2.0 / 3.0);
                Vector2 p3p = fun.PointRotate(p0, p1p, -pi * 2.0 / 3.0);
                Vector2 p1 = fun.Polar(p0, pi / 2 + ang1, d1 / 2.0);
                Vector2 p2 = fun.Polar(p0, pi / 2 + ang2, d / 2.0);
                Vector2 p3 = fun.Polar(p0, pi / 2 - ang1, d1 / 2.0);
                Vector2 p4 = fun.Polar(p0, pi / 2 - ang2, d / 2.0);

                Vector2 p5 = fun.PointRotate(p0, p1, pi * 2.0 / 3.0);
                Vector2 p6 = fun.PointRotate(p0, p2, pi * 2.0 / 3.0);
                Vector2 p7 = fun.PointRotate(p0, p3, pi * 2.0 / 3.0);
                Vector2 p8 = fun.PointRotate(p0, p4, pi * 2.0 / 3.0);

                Vector2 p9 = fun.PointRotate(p0, p1, -pi * 2.0 / 3.0);
                Vector2 p10 = fun.PointRotate(p0, p2, -pi * 2.0 / 3.0);
                Vector2 p11 = fun.PointRotate(p0, p3, -pi * 2.0 / 3.0);
                Vector2 p12 = fun.PointRotate(p0, p4, -pi * 2.0 / 3.0);

                Vector2 p13 = fun.Polar(p0, pi / 2 + 5 * pi / 180, D / 2);
                Vector2 p14 = fun.Polar(p0, pi / 2 - 5 * pi / 180, D / 2);
                Vector2 p15 = fun.Polar(p0, pi / 2 + 5 * pi / 180, D / 2);
                Vector2 p16 = fun.Polar(p0, pi / 2 - 5 * pi / 180, D / 2);

                Vector2 p17 = fun.Polar(p0, pi / 2 + 5 * pi / 180, D / 2);
                Vector2 p18 = fun.Polar(p0, pi / 2 - 5 * pi / 180, D / 2);
                Vector2 p18_ = fun.Polar(p0, pi / -2, D / 2);
                Vector2 p19 = fun.Polar(p0, pi / 2 + 5 * pi / 180, D1 / 2);
                Vector2 p20 = fun.Polar(p0, pi / 2 - 5 * pi / 180, D1 / 2);
                Arc arc10 = fun.DrawArc(p17, p0, p18);
                // dxf.AddEntity(arc10);
                fun.drawBArc(dxf, arc10, 0.1, contour);


                //外槽
                Vector2 p21 = fun.Polar(p0, pi / -2, Math.Sqrt(((D / 2) * (D / 2)) - (b / 2) * (b / 2)));
                Vector2 p22 = fun.Polar(p21, pi, b / 2);
                Vector2 p23 = fun.Polar(p21, 0, b / 2);
                Vector2 p24 = fun.Polar(p21, pi / 2, b / 2);
                Vector2 p25_ = fun.PointRotate(p0, p24, -(pi * 3.0 / 4.0));
                Vector2 p25 = fun.Polar(p25_, -pi / 4, c);
                Vector2 p26_ = fun.Polar(p25, pi / 2, 50);

                Vector2 p26 = fun.Inters1(p25, p26_, arc10, 2);

                Vector2 p27_ = fun.Polar(p25, 0, 50);
                Vector2 p27 = fun.Inters1(p25, p27_, arc10, 1);

                Vector2 p28_ = fun.PointRotate(p0, p24, (pi * 3.0 / 4.0));
                Vector2 p28 = fun.Polar(p28_, pi + pi / 4, c);

                Vector2 p29 = fun.mirrorpoint(p26, zx1, zx2);
                Vector2 p30 = fun.mirrorpoint(p27, zx1, zx2);
                Vector2 p40 = fun.Polar(p0, pi / -2, D / 2);
                Vector2 p41 = fun.Polar(p40, 0, D * 2);
                Vector2 p42 = fun.Polar(p41, pi / 2, a);
                Vector2 p43 = fun.Polar(p41, pi / 2, D / 2 - DD1 / 2);
                Vector2 p44 = fun.Polar(p43, pi / 2, DD1 / 4);
                Vector2 p45 = fun.Polar(p44, pi / 2, (d - d1) / 2.0);
                Vector2 p46 = fun.Polar(p43, pi / 2, DD1 / 2);
                Vector2 p47 = fun.Polar(p46, pi / 2, (DD1 / 2.0 / 3.0));
                Vector2 p48 = fun.Polar(p47, pi / 2, (d - d1) / 2.0);
                Vector2 p49 = fun.Polar(p47, pi / 2, (DD1 / 2.0 / 3.0));
                Vector2 p50 = fun.Polar(p49, pi / 2, (d - d1) / 2.0);
                Vector2 p51 = fun.Polar(p43, pi / 2, DD1);
                Vector2 p52 = fun.Polar(p41, pi / 2, D);
                Vector2 p53 = fun.Polar(p52, 0, E - a);
                Vector2 p54 = fun.Polar(p53, pi / -4, Math.Sqrt(2) * a);
                Vector2 p55 = fun.Polar(p54, pi / -2, (D / 2.0) - (D1 / 2.0) - a);
                Vector2 p56 = fun.Polar(p46, 0, E);
                Vector2 p57 = fun.Polar(p55, pi / -2, D1);
                Vector2 p58 = fun.Polar(p57, pi / -2, (D / 2.0) - (D1 / 2.0) - a);
                Vector2 p59 = fun.Polar(p58, pi / -2 + pi / -4, Math.Sqrt(2) * a);
                Vector2 p60 = fun.Polar(p59, pi, E / 2.0 - a - b / 2);
                Vector2 p61 = fun.Polar(p60, pi - pi / 4, b / (Math.Sqrt(2)));
                Vector2 p62 = fun.Polar(p61, pi + pi / 4, b / (Math.Sqrt(2)));
                Vector2 p63 = fun.Polar(p62, pi, E / 2.0 - b / 2.0 - a);
                Vector2 p64 = fun.Polar(p55, pi, E - E1);
                Vector2 p65 = fun.Polar(p57, pi, E - E1);
                Vector2 p66 = fun.Polar(p51, 0, E1);
                Vector2 p67 = fun.Polar(p43, 0, E1);
                Vector2 p68 = fun.Polar(p44, pi / 4, Math.Sqrt(2) * (E1 / 3.0));
                Vector2 p69 = fun.Polar(p68, 0, E1 / 3.0);
                Vector2 p70 = fun.Polar(p44, 0, E1);
                Vector2 p71 = fun.Polar(p68, pi / 2, (d - d1) / 2.0);
                Vector2 p72 = fun.Polar(p69, pi / 2, (d - d1) / 2.0);
                Vector2 p73 = fun.Polar(p45, 0, E1);
                Vector2 p74 = fun.Polar(p47, pi / -4, Math.Sqrt(2) * (E1 / 3.0));
                Vector2 p75 = fun.Polar(p74, 0, E1 / 3.0);
                Vector2 p76 = fun.Polar(p47, 0, E1);
                Vector2 p77 = fun.Polar(p74, pi / 2, (d - d1) / 2.0);
                Vector2 p78 = fun.Polar(p75, pi / 2, (d - d1) / 2.0);
                Vector2 p79 = fun.Polar(p48, 0, E1);
                Vector2 p80 = fun.Polar(p49, pi / -4, Math.Sqrt(2) * (E1 / 3.0));
                Vector2 p81 = fun.Polar(p80, 0, E1 / 3.0);
                Vector2 p82 = fun.Polar(p49, 0, E1);
                Vector2 p83 = fun.Polar(p80, pi / 2, (d - d1) / 2.0);
                Vector2 p84 = fun.Polar(p81, pi / 2, (d - d1) / 2.0);
                Vector2 p85 = fun.Polar(p50, 0, E1);

                Line line4 = new Line(p23, p24);
                fun.drawBline(dxf, line4, 0.1, contour);

                Line line5 = new Line(p24, p22);
                fun.drawBline(dxf, line5, 0.1, contour);


                Line line6 = new Line(p25, p26);
                fun.drawBline(dxf, line6, 0.1, contour);

                Line line7 = new Line(p27, p25);
                line7.Linetype = Linetype.DashDot;//Linetype指是点划线还是虚线什么的
                fun.drawBline(dxf, line7, 0.1, contour);

                Line line8 = new Line(p29, p28);
                fun.drawBline(dxf, line8, 0.1, contour);

                Line line9 = new Line(p30, p28);
                fun.drawBline(dxf, line9, 0.1, contour);

                Line line10 = new Line(fun.Polar(p0, pi, D / 2 + 5), fun.Polar(p0, 0, D / 2 + 5));
                Line line11 = new Line(fun.Polar(p0, pi / 2, D / 2 + 5), fun.Polar(p0, pi / -2, D / 2 + 5));
                line10.Lineweight = Lineweight.W25;//Lineweight指线宽
                line10.Layer = center;//Layer指图层
                line10.Linetype = Linetype.DashDot;//Linetype指是点划线还是虚线什么的
                dxf.AddEntity(line10);
                line11.Lineweight = Lineweight.W25;//Lineweight指线宽
                line11.Layer = center;//Layer指图层
                line11.Linetype = Linetype.DashDot;//Linetype指是点划线还是虚线什么的
                dxf.AddEntity(line11);

                Arc arc1 = fun.DrawArc(p3, p1p, p1);
                fun.drawBArc(dxf, arc1, 0.1, contour);
                Arc arc2 = fun.DrawArc(p7, p2p, p5);
                fun.drawBArc(dxf, arc2, 0.1, contour);
                Arc arc3 = fun.DrawArc(p11, p3p, p9);
                fun.drawBArc(dxf, arc3, 0.1, contour);
                Arc arc4 = fun.DrawArc(p6, p0, p4);
                fun.drawBArc(dxf, arc4, 0.1, contour);
                Arc arc5 = fun.DrawArc(p10, p0, p8);
                fun.drawBArc(dxf, arc5, 0.1, contour);
                Arc arc6 = fun.DrawArc(p2, p0, p12);
                fun.drawBArc(dxf, arc6, 0.1, contour);

                Arc arc7 = fun.DrawArc(p5, p0, p3);
                fun.drawBArc(dxf, arc7, 0.1, contour);
                Arc arc8 = fun.DrawArc(p9, p0, p7);
                fun.drawBArc(dxf, arc8, 0.1, contour);
                Arc arc9 = fun.DrawArc(p1, p0, p11);
                fun.drawBArc(dxf, arc9, 0.1, contour);

                LwPolyline poly1 = new LwPolyline();
                poly1.Vertexes.Add(new LwPolylineVertex(p42));
                poly1.Vertexes.Add(new LwPolylineVertex(p52));
                poly1.Vertexes.Add(new LwPolylineVertex(p53));
                poly1.Vertexes[2].Bulge = -Math.Tan((pi / 2) / 4);
                poly1.Vertexes.Add(new LwPolylineVertex(p54));
                poly1.Vertexes.Add(new LwPolylineVertex(p58));
                poly1.Vertexes[4].Bulge = -Math.Tan((pi / 2) / 4);
                poly1.Vertexes.Add(new LwPolylineVertex(p59));
                poly1.Vertexes.Add(new LwPolylineVertex(p63));
                poly1.Vertexes[6].Bulge = -Math.Tan((pi / 2) / 4);
                poly1.Vertexes.Add(new LwPolylineVertex(p42));
                fun.PolyFill(dxf, poly1, 0.1, contour);

                LwPolyline poly2 = new LwPolyline();
                poly2.Vertexes.Add(new LwPolylineVertex(p51));
                poly2.Vertexes.Add(new LwPolylineVertex(p43));
                poly2.Vertexes.Add(new LwPolylineVertex(p67));
                poly2.Vertexes.Add(new LwPolylineVertex(p66));
                poly2.Vertexes.Add(new LwPolylineVertex(p51));
                fun.PolyFill(dxf, poly2, 0.1, contour);


                LwPolyline poly3 = new LwPolyline();
                poly3.Vertexes.Add(new LwPolylineVertex(p55));
                poly3.Vertexes.Add(new LwPolylineVertex(p64));
                poly3.Vertexes.Add(new LwPolylineVertex(p65));
                poly3.Vertexes.Add(new LwPolylineVertex(p57));
                poly3.Vertexes.Add(new LwPolylineVertex(p55));
                fun.PolyFill(dxf, poly3, 0.1, contour);

                LwPolyline poly4 = new LwPolyline();
                poly4.Vertexes.Add(new LwPolylineVertex(p51));
                poly4.Vertexes.Add(new LwPolylineVertex(p52));
                poly4.Vertexes.Add(new LwPolylineVertex(p53));
                poly4.Vertexes[2].Bulge = -Math.Tan((pi / 2) / 4);
                poly4.Vertexes.Add(new LwPolylineVertex(p54));
                poly4.Vertexes.Add(new LwPolylineVertex(p55));
                poly4.Vertexes.Add(new LwPolylineVertex(p64));
                poly4.Vertexes.Add(new LwPolylineVertex(p66));
                poly4.Vertexes.Add(new LwPolylineVertex(p51));
                poly4.IsClosed = true;
                fun.PolyFill(dxf, poly4, 0.1, contour);//将poly1这条线设置为宽度0.4的实体，contour轮廓实体。
                String[] htype1 = new String[100];
                Line[] hline1 = new Line[100];
                Arc[] harc1 = new Arc[100];
                int hnumst1 = poly4.Explode().Count;  //记录爆炸后，线段有多少
                for (int i = 0; i < hnumst1; i++)
                {
                    htype1[i] = poly4.Explode()[i].Type.ToString();    //将所有元素的类型记录成一个数组
                    if (htype1[i] == "Line")
                    {
                        hline1[i] = (Line)poly4.Explode()[i];
                    }
                    if (htype1[i] == "Arc")
                    {
                        harc1[i] = (Arc)poly4.Explode()[i];
                    }
                }
                fun.hatchsub1(dxf, htype1, hnumst1, 45, 1, hline1, harc1, hatching);


                LwPolyline poly5 = new LwPolyline();
                poly5.Vertexes.Add(new LwPolylineVertex(p42));
                poly5.Vertexes.Add(new LwPolylineVertex(p43));
                poly5.Vertexes.Add(new LwPolylineVertex(p67));
                poly5.Vertexes.Add(new LwPolylineVertex(p65));
                poly5.Vertexes.Add(new LwPolylineVertex(p57));
                poly5.Vertexes.Add(new LwPolylineVertex(p58));
                poly5.Vertexes[5].Bulge = -Math.Tan((pi / 2) / 4);
                poly5.Vertexes.Add(new LwPolylineVertex(p59));
                poly5.Vertexes.Add(new LwPolylineVertex(p60));
                poly5.Vertexes.Add(new LwPolylineVertex(p61));
                poly5.Vertexes.Add(new LwPolylineVertex(p62));
                poly5.Vertexes.Add(new LwPolylineVertex(p63));
                poly5.Vertexes[10].Bulge = -Math.Tan((pi / 2) / 4);
                poly5.Vertexes.Add(new LwPolylineVertex(p42));
                poly5.IsClosed = true;
                fun.PolyFill(dxf, poly5, 0.1, contour);//将poly1这条线设置为宽度0.4的实体，contour轮廓实体。
                String[] htype2 = new String[100];
                Line[] hline2 = new Line[100];
                Arc[] harc2 = new Arc[100];
                int hnumst2 = poly5.Explode().Count;  //记录爆炸后，线段有多少
                for (int i = 0; i < hnumst2; i++)
                {
                    htype2[i] = poly5.Explode()[i].Type.ToString();    //将所有元素的类型记录成一个数组
                    if (htype2[i] == "Line")
                    {
                        hline2[i] = (Line)poly5.Explode()[i];
                    }
                    if (htype2[i] == "Arc")
                    {
                        harc2[i] = (Arc)poly5.Explode()[i];
                    }
                }
                fun.hatchsub1(dxf, htype2, hnumst2, 45, 1, hline2, harc2, hatching);



                LwPolyline poly6 = new LwPolyline();
                poly6.Vertexes.Add(new LwPolylineVertex(p44));
                poly6.Vertexes.Add(new LwPolylineVertex(p45));
                poly6.Vertexes.Add(new LwPolylineVertex(p71));
                poly6.Vertexes.Add(new LwPolylineVertex(p72));
                poly6.Vertexes.Add(new LwPolylineVertex(p73));
                poly6.Vertexes.Add(new LwPolylineVertex(p70));
                poly6.Vertexes.Add(new LwPolylineVertex(p69));
                poly6.Vertexes.Add(new LwPolylineVertex(p68));
                poly6.Vertexes.Add(new LwPolylineVertex(p44));
                poly6.Vertexes.Add(new LwPolylineVertex(p68));
                poly6.Vertexes.Add(new LwPolylineVertex(p71));
                poly6.Vertexes.Add(new LwPolylineVertex(p72));
                poly6.Vertexes.Add(new LwPolylineVertex(p69));
                fun.PolyFill(dxf, poly6, 0.1, contour);

                LwPolyline poly7 = new LwPolyline();
                poly7.Vertexes.Add(new LwPolylineVertex(p47));
                poly7.Vertexes.Add(new LwPolylineVertex(p48));
                poly7.Vertexes.Add(new LwPolylineVertex(p77));
                poly7.Vertexes.Add(new LwPolylineVertex(p78));
                poly7.Vertexes.Add(new LwPolylineVertex(p79));
                poly7.Vertexes.Add(new LwPolylineVertex(p76));
                poly7.Vertexes.Add(new LwPolylineVertex(p75));
                poly7.Vertexes.Add(new LwPolylineVertex(p74));
                poly7.Vertexes.Add(new LwPolylineVertex(p47));
                poly7.Vertexes.Add(new LwPolylineVertex(p74));
                poly7.Vertexes.Add(new LwPolylineVertex(p77));
                poly7.Vertexes.Add(new LwPolylineVertex(p78));
                poly7.Vertexes.Add(new LwPolylineVertex(p75));
                fun.PolyFill(dxf, poly7, 0.1, contour);

                LwPolyline poly8 = new LwPolyline();
                poly8.Vertexes.Add(new LwPolylineVertex(p49));
                poly8.Vertexes.Add(new LwPolylineVertex(p50));
                poly8.Vertexes.Add(new LwPolylineVertex(p83));
                poly8.Vertexes.Add(new LwPolylineVertex(p84));
                poly8.Vertexes.Add(new LwPolylineVertex(p85));
                poly8.Vertexes.Add(new LwPolylineVertex(p82));
                poly8.Vertexes.Add(new LwPolylineVertex(p81));
                poly8.Vertexes.Add(new LwPolylineVertex(p80));
                poly8.Vertexes.Add(new LwPolylineVertex(p49));
                poly8.Vertexes.Add(new LwPolylineVertex(p80));
                poly8.Vertexes.Add(new LwPolylineVertex(p83));
                poly8.Vertexes.Add(new LwPolylineVertex(p84));
                poly8.Vertexes.Add(new LwPolylineVertex(p81));
                fun.PolyFill(dxf, poly8, 0.1, contour);

                Circle circle1 = new Circle(new Vector3(0, 0, 0), D1 / 2);
                //dxf.AddEntity(circle1);
                fun.drawcircle(dxf, p0, D1 / 2, 0.1, contour);
                Line line1 = new Line(p17, p19);
                Line line2 = new Line(p18, p20);
                // dxf.AddEntity(line1);
                //dxf.AddEntity(line2);
                fun.drawBline(dxf, line1, 0.1, contour);
                fun.drawBline(dxf, line2, 0.1, contour);


                Vector2 zx5 = fun.Polar(p46, pi, 4);
                Vector2 zx6 = fun.Polar(p56, 0, 4);
                Line line13 = new Line(zx5, zx6);
                line13.Lineweight = Lineweight.W25;//Lineweight指线宽
                line13.Layer = center;//Layer指图层
                line13.Linetype = Linetype.DashDot;//Linetype指是点划线还是虚线什么的
                dxf.AddEntity(line13);



                //标注

                DimensionStyle dimensionStyle = new DimensionStyle("sd");
                dimensionStyle.ArrowSize = 1.6;
                dimensionStyle.DimArrow1 = DimensionArrowhead.Closedfilled;
                dimensionStyle.DimArrow2 = DimensionArrowhead.Closedfilled;
                dimensionStyle.TextHeight = 1.2;
                double offset = D;




                fun.dimrot1(dxf, p25, p0, -45, D / 2/scale , 2, 1.6, 1.2, 0.9, "c=" + c, "", "");
                fun.dimrot1(dxf, p28, p0, 45, D / 2 / scale, 2, 1.6, 1.2, 0.9, "c=" + c, "", "");
                fun.dimrot1(dxf, p52, p54, 0, E * 2 / scale, 2, 1.6, 1.2, 0.9, "E=" + E, "", "");
                fun.dimrot1(dxf, p51, p64, 0, E / scale, 2, 1.6, 1.2, 0.9, "E1=" + E1, "", "");
                fun.dimrot1(dxf, p55, p57, -90, E / scale, 2, 1.6, 1.2, 0.9, "D1=" + D1, "", "");
                fun.dimrot1(dxf, p53, p59, -90, E * 2 / scale, 2, 1.6, 1.2, 0.9, "D=" + D, "", "");
                //  fun.dimrot1(dxf, p42, p63, 180, E, 2, 1.6, 1.2, 0.9, "a×45", "", "");
                // fun.dimrot1(dxf, p59, p58, 180, E, 2, 1.6, 1.2, 0.9, "a×45", "", "");
                LinearDimension dim2 = new LinearDimension(new Line(p42, p63), offset / scale, 180, dimensionStyle);
                dim2.UserText = "a×45";
                dxf.AddEntity(dim2);
                LinearDimension dim3 = new LinearDimension(new Line(p59, p58), offset / scale, 180, dimensionStyle);
                dim3.UserText = "a×45";
                dxf.AddEntity(dim3);

                fun.dimrot1(dxf, p62, p60, 180, D / 2.0 / scale, 2, 1.6, 1.2, 0.9, "b=" + b, "", "");
                fun.dimrot1(dxf, p42, p61, 180, D + 8 / scale, 2, 1.6, 1.2, 0.9, "0.5E", "", "");




                fun.jdbz2(dxf, new Line(p0, fun.Polar(p0, pi / 2, 0.1)), new Line(p0, fun.Polar(p0, pi / 2 + pi / 4, 0.1)), D / scale, 1.6, 1.2, 0.9, "45" + "°", "", "");
                fun.jdbz2(dxf, new Line(p0, fun.Polar(p0, pi / 2 - pi / 4, 0.1)), new Line(p0, fun.Polar(p0, pi / 2, 0.1)), D / scale, 1.6, 1.2, 0.9, "45" + "°", "", "");


            }
            else
            {
                Vector2 zx1 = new Vector2(0, D / 2 + 5);
                Vector2 zx2 = new Vector2(0, D / -2 - 5);
                Vector2 zx3 = new Vector2(D / 2 + 5, 0);
                Vector2 zx4 = new Vector2(D / -2 - 5, 0);


                Vector2 p0 = new Vector2(0, 0);
                Vector2 p1p = fun.Polar(p0, pi / 2, d1 / 2 - 0.1 + pxk / 2.0);
                Vector2 p2p = fun.PointRotate(p0, p1p, (pi * 2.0 / 5.0));
                Vector2 p3p = fun.PointRotate(p0, p1p, (pi * 2.0 / 5.0) * 2);
                Vector2 p4p = fun.PointRotate(p0, p1p, (pi * 2.0 / 5.0) * 3);
                Vector2 p5p = fun.PointRotate(p0, p1p, (pi * 2.0 / 5.0) * 4);
                Vector2 p6p = fun.PointRotate(p0, p1p, (pi * 2.0 / 5.0) * 5);

                Vector2 p1 = fun.Polar(p0, pi / 2 + ang1, d1 / 2.0);
                Vector2 p2 = fun.Polar(p0, pi / 2 + ang2, d / 2.0);
                Vector2 p3 = fun.Polar(p0, pi / 2 - ang1, d1 / 2.0);
                Vector2 p4 = fun.Polar(p0, pi / 2 - ang2, d / 2.0);

                Vector2 p5 = fun.PointRotate(p0, p1, (pi * 2.0 / 5.0));
                Vector2 p6 = fun.PointRotate(p0, p2, (pi * 2.0 / 5.0));
                Vector2 p7 = fun.PointRotate(p0, p3, (pi * 2.0 / 5.0));
                Vector2 p8 = fun.PointRotate(p0, p4, (pi * 2.0 / 5.0));

                Vector2 p9 = fun.PointRotate(p0, p1, (pi * 2.0 / 5.0) * 2);
                Vector2 p10 = fun.PointRotate(p0, p2, (pi * 2.0 / 5.0) * 2);
                Vector2 p11 = fun.PointRotate(p0, p3, (pi * 2.0 / 5.0) * 2);
                Vector2 p12 = fun.PointRotate(p0, p4, (pi * 2.0 / 5.0) * 2);

                Vector2 p13 = fun.PointRotate(p0, p1, (pi * 2.0 / 5.0) * 3);
                Vector2 p14 = fun.PointRotate(p0, p2, (pi * 2.0 / 5.0) * 3);
                Vector2 p15 = fun.PointRotate(p0, p3, (pi * 2.0 / 5.0) * 3);
                Vector2 p16 = fun.PointRotate(p0, p4, (pi * 2.0 / 5.0) * 3);

                Vector2 p17 = fun.PointRotate(p0, p1, (pi * 2.0 / 5.0) * 4);
                Vector2 p18 = fun.PointRotate(p0, p2, (pi * 2.0 / 5.0) * 4);
                Vector2 p19 = fun.PointRotate(p0, p3, (pi * 2.0 / 5.0) * 4);
                Vector2 p20 = fun.PointRotate(p0, p4, (pi * 2.0 / 5.0) * 4);
                //卡槽
                Vector2 p21 = fun.Polar(p0, pi / 2 + 5 * pi / 180, D / 2);
                Vector2 p22 = fun.Polar(p0, pi / 2 + 5 * pi / 180, D1 / 2);
                Vector2 p23 = fun.Polar(p0, pi / 2 + 5 * pi / 180, DD1 / 2);

                Vector2 p24 = fun.Polar(p0, pi / 2 - 5 * pi / 180, D / 2);
                Vector2 p24_ = fun.Polar(p0, pi / -2, D / 2);
                Vector2 p25 = fun.Polar(p0, pi / 2 - 5 * pi / 180, D1 / 2);
                Vector2 p26 = fun.Polar(p0, pi / 2 - 5 * pi / 180, DD1 / 2);
                Arc arc18 = fun.DrawArc(p21, p0, p24_);
                // dxf.AddEntity(arc10);
                fun.drawBArc(dxf, arc18, 0.1, contour);
                Arc arc19 = fun.DrawArc(p24_, p0, p24);
                // dxf.AddEntity(arc19);
                fun.drawBArc(dxf, arc19, 0.1, contour);

                //四个槽孔
                Vector2 p27 = fun.Polar(p0, pi / -4, Math.Sqrt(((D / 2) * (D / 2)) - (b / 2) * (b / 2)));
                Vector2 p28 = fun.Polar(p27, pi + pi / 4, b / 2);
                Vector2 p29 = fun.Polar(p27, pi / 4, b / 2);
                Vector2 p30 = fun.Polar(p27, pi / 2 + pi / 4, b / 2);
                Vector2 p31 = fun.PointRotate(p0, p30, (pi / 2));
                Vector2 p32_ = fun.Polar(p31, pi, 50);
                Vector2 p32 = fun.Inters1(p31, p32_, arc18, 2);
                Vector2 p33 = fun.Polar(p32, pi / -4, b);
                Vector2 p34_ = fun.PointRotate(p0, p30, (pi / -2));
                Vector2 p34 = fun.Polar(p34_, pi / -4, c);
                Vector2 p35_ = new Vector2(p34.X, p34.Y + 10);


                Vector2 p35 = fun.Inters1(p34, p35_, arc19, 1);
                Vector2 p36_ = fun.Polar(p34, 0, 50);
                Vector2 p36 = fun.Inters1(p34, p36_, arc19, 1);
                Vector2 p37 = fun.mirrorpoint(p34, zx1, zx2);
                Vector2 p38 = fun.mirrorpoint(p35, zx1, zx2);
                Vector2 p39 = fun.mirrorpoint(p36, zx1, zx2);

                Vector2 p40 = fun.Polar(p0, pi / -2, D / 2);
                Vector2 p41 = fun.Polar(p40, 0, D * 2);
                Vector2 p42 = fun.Polar(p41, pi / 2, a);
                Vector2 p43 = fun.Polar(p41, pi / 2, D / 2 - DD1 / 2);
                Vector2 p44 = fun.Polar(p43, pi / 2, DD1 / 4);
                Vector2 p45 = fun.Polar(p44, pi / 2, (d - d1) / 2.0);
                Vector2 p46 = fun.Polar(p43, pi / 2, DD1 / 2);
                Vector2 p47 = fun.Polar(p46, pi / 2, (DD1 / 2.0 / 3.0));
                Vector2 p48 = fun.Polar(p47, pi / 2, (d - d1) / 2.0);
                Vector2 p49 = fun.Polar(p47, pi / 2, (DD1 / 2.0 / 3.0));
                Vector2 p50 = fun.Polar(p49, pi / 2, (d - d1) / 2.0);
                Vector2 p51 = fun.Polar(p43, pi / 2, DD1);
                Vector2 p52 = fun.Polar(p41, pi / 2, D);
                Vector2 p53 = fun.Polar(p52, 0, E - a);
                Vector2 p54 = fun.Polar(p53, pi / -4, Math.Sqrt(2) * a);
                Vector2 p55 = fun.Polar(p54, pi / -2, (D / 2.0) - (D1 / 2.0) - a);
                Vector2 p56 = fun.Polar(p46, 0, E);
                Vector2 p57 = fun.Polar(p55, pi / -2, D1);
                Vector2 p58 = fun.Polar(p57, pi / -2, (D / 2.0) - (D1 / 2.0) - a);
                Vector2 p59 = fun.Polar(p58, pi / -2 + pi / -4, Math.Sqrt(2) * a);
                Vector2 p60 = fun.Polar(p59, pi, E / 2.0 - a - b / 2);
                Vector2 p61 = fun.Polar(p60, pi - pi / 4, b / (Math.Sqrt(2)));
                Vector2 p62 = fun.Polar(p61, pi + pi / 4, b / (Math.Sqrt(2)));
                Vector2 p63 = fun.Polar(p62, pi, E / 2.0 - b / 2.0 - a);
                Vector2 p64 = fun.Polar(p55, pi, E - E1);
                Vector2 p65 = fun.Polar(p57, pi, E - E1);
                Vector2 p66 = fun.Polar(p51, 0, E1);
                Vector2 p67 = fun.Polar(p43, 0, E1);

                Vector2 p68;
                Vector2 p69;
                Vector2 p70;
                Vector2 p71;
                Vector2 p72;
                Vector2 p73;
                Vector2 p74;
                Vector2 p75;
                Vector2 p76;
                Vector2 p77;
                Vector2 p78;
                Vector2 p79;
                Vector2 p80;
                Vector2 p81;
                Vector2 p82;
                Vector2 p83;
                Vector2 p84;


                if (D >= 25 * scale && pd1 != 0)
                {
                    p68 = fun.Polar(p44, pi / 4, Math.Sqrt(2) * (E1 / 10.0));
                    p69 = fun.Polar(p68, 0, E1 / 10.0 * 8);
                    p70 = fun.Polar(p44, 0, E1);
                    p71 = fun.Polar(p68, pi / 2, (d - d1) / 2.0);
                    p72 = fun.Polar(p69, pi / 2, (d - d1) / 2.0);
                    p73 = fun.Polar(p45, 0, E1);
                    p74 = fun.Polar(p47, pi / -4, Math.Sqrt(2) * (E1 / 10.0));
                    p75 = fun.Polar(p74, 0, E1 / 10.0 * 8);
                    p76 = fun.Polar(p47, 0, E1);
                    p77 = fun.Polar(p74, pi / 2, (d - d1) / 2.0);
                    p78 = fun.Polar(p75, pi / 2, (d - d1) / 2.0);
                    p79 = fun.Polar(p48, 0, E1);
                    p80 = fun.Polar(p49, pi / -4, Math.Sqrt(2) * (E1 / 10.0));
                    p81 = fun.Polar(p80, 0, E1 / 10.0 * 8);
                    p82 = fun.Polar(p49, 0, E1);
                    p83 = fun.Polar(p80, pi / 2, (d - d1) / 2.0);
                    p84 = fun.Polar(p81, pi / 2, (d - d1) / 2.0);

                }


                else
                {
                    p68 = fun.Polar(p44, pi / 4, Math.Sqrt(2) * (E1 / 3.0));
                    p69 = fun.Polar(p68, 0, E1 / 3.0);
                    p70 = fun.Polar(p44, 0, E1);
                    p71 = fun.Polar(p68, pi / 2, (d - d1) / 2.0);
                    p72 = fun.Polar(p69, pi / 2, (d - d1) / 2.0);
                    p73 = fun.Polar(p45, 0, E1);
                    p74 = fun.Polar(p47, pi / -4, Math.Sqrt(2) * (E1 / 3.0));
                    p75 = fun.Polar(p74, 0, E1 / 3.0);
                    p76 = fun.Polar(p47, 0, E1);
                    p77 = fun.Polar(p74, pi / 2, (d - d1) / 2.0);
                    p78 = fun.Polar(p75, pi / 2, (d - d1) / 2.0);
                    p79 = fun.Polar(p48, 0, E1);
                    p80 = fun.Polar(p49, pi / -4, Math.Sqrt(2) * (E1 / 3.0));
                    p81 = fun.Polar(p80, 0, E1 / 3.0);
                    p82 = fun.Polar(p49, 0, E1);
                    p83 = fun.Polar(p80, pi / 2, (d - d1) / 2.0);
                    p84 = fun.Polar(p81, pi / 2, (d - d1) / 2.0);
                }
                Vector2 p85 = fun.Polar(p50, 0, E1);
                //刨线
                Vector2 p86 = fun.Polar(p0, px, D / 2 + 4);
                Vector2 p87 = fun.Polar(p86, px, 4);
                Vector2 p88 = fun.Polar(p87, px - pi / 2, 4);
                Vector2 p89 = fun.Polar(p88, px, 1.2 * Math.Tan(10 * pi / 180));
                Vector2 p90 = fun.Polar(p88, px - pi, 1.2 * Math.Tan(10 * pi / 180));
                Vector2 p91 = fun.Polar(p88, px - pi / 2, 1.2);
                Vector2 p92 = fun.Polar(p0, pi / -4, D / 2 + 4);
                Vector2 p93 = fun.Polar(p92, pi / -4, 4);
                Vector2 p94 = fun.Polar(p93, pi / -4 + pi / 2, 4);
                Vector2 p95 = fun.Polar(p94, pi / -4 - pi, 1.2 * Math.Tan(10 * pi / 180));
                Vector2 p96 = fun.Polar(p94, pi / -4, 1.2 * Math.Tan(10 * pi / 180));
                Vector2 p97 = fun.Polar(p94, pi / -4 + pi / 2, 1.2);


                Vector2 zx5 = fun.Polar(p46, pi, 4);
                Vector2 zx6 = fun.Polar(p56, 0, 4);




                Line line3 = new Line(p28, p30);
                fun.drawBline(dxf, line3, 0.1, contour);
                Line line4 = new Line(p29, p30);
                fun.drawBline(dxf, line4, 0.1, contour);
                Line line5 = new Line(p32, p31);
                fun.drawBline(dxf, line5, 0.1, contour);
                Line line6 = new Line(p33, p31);
                fun.drawBline(dxf, line6, 0.1, contour);
                Line line7 = new Line(p34, p36);
                fun.drawBline(dxf, line7, 0.1, contour);
                Line line8 = new Line(p34, p35);
                fun.drawBline(dxf, line8, 0.1, contour);
                Line line9 = new Line(p37, p39);
                fun.drawBline(dxf, line9, 0.1, contour);
                Line line10 = new Line(p37, p38);
                fun.drawBline(dxf, line10, 0.1, contour);



                Arc arc1 = fun.DrawArc(p3, p1p, p1);
                fun.drawBArc(dxf, arc1, 0.1, contour);
                Arc arc2 = fun.DrawArc(p7, p2p, p5);
                fun.drawBArc(dxf, arc2, 0.1, contour);
                Arc arc3 = fun.DrawArc(p11, p3p, p9);
                fun.drawBArc(dxf, arc3, 0.1, contour);
                Arc arc4 = fun.DrawArc(p15, p4p, p13);
                fun.drawBArc(dxf, arc4, 0.1, contour);
                Arc arc5 = fun.DrawArc(p19, p5p, p17);
                fun.drawBArc(dxf, arc5, 0.1, contour);
                Arc arc6 = fun.DrawArc(p6, p0, p4);
                fun.drawBArc(dxf, arc6, 0.1, contour);
                Arc arc7 = fun.DrawArc(p5, p0, p3);
                fun.drawBArc(dxf, arc7, 0.1, contour);
                Arc arc8 = fun.DrawArc(p10, p0, p8);
                fun.drawBArc(dxf, arc8, 0.1, contour);
                Arc arc9 = fun.DrawArc(p9, p0, p7);
                fun.drawBArc(dxf, arc9, 0.1, contour);
                Arc arc10 = fun.DrawArc(p14, p0, p12);
                fun.drawBArc(dxf, arc10, 0.1, contour);
                Arc arc11 = fun.DrawArc(p13, p0, p11);
                fun.drawBArc(dxf, arc11, 0.1, contour);
                Arc arc12 = fun.DrawArc(p18, p0, p16);
                fun.drawBArc(dxf, arc12, 0.1, contour);
                Arc arc13 = fun.DrawArc(p17, p0, p15);
                fun.drawBArc(dxf, arc13, 0.1, contour);
                Arc arc14 = fun.DrawArc(p2, p0, p20);
                fun.drawBArc(dxf, arc14, 0.1, contour);
                Arc arc15 = fun.DrawArc(p1, p0, p19);
                fun.drawBArc(dxf, arc15, 0.1, contour);

                Arc arc16 = fun.DrawArc(p21, p0, p24);
                fun.drawBArc(dxf, arc16, 0.1, contour);
                Arc arc17 = fun.DrawArc(p22, p0, p25);
                fun.drawBArc(dxf, arc17, 0.1, contour);






                Circle circle1 = new Circle(new Vector3(0, 0, 0), DD1 / 2);
                //dxf.AddEntity(circle1);
                fun.drawcircle(dxf, p0, DD1 / 2, 0.1, contour);

                Line line1 = new Line(p21, p23);
                Line line2 = new Line(p24, p26);
                fun.drawBline(dxf, line1, 0.1, contour);
                fun.drawBline(dxf, line2, 0.1, contour);



                //中心线

                Line line11 = new Line(zx1, zx2);
                line11.Lineweight = Lineweight.W25;//Lineweight指线宽
                line11.Layer = center;//Layer指图层
                line11.Linetype = Linetype.DashDot;//Linetype指是点划线还是虚线什么的
                dxf.AddEntity(line11);

                Line line12 = new Line(zx3, zx4);
                line12.Lineweight = Lineweight.W25;//Lineweight指线宽
                line12.Layer = center;//Layer指图层
                line12.Linetype = Linetype.DashDot;//Linetype指是点划线还是虚线什么的
                dxf.AddEntity(line12);

                Line line13 = new Line(zx5, zx6);
                line13.Lineweight = Lineweight.W25;//Lineweight指线宽
                line13.Layer = center;//Layer指图层
                line13.Linetype = Linetype.DashDot;//Linetype指是点划线还是虚线什么的
                dxf.AddEntity(line13);

                /*
                Vector2 p13 = fun.Polar(p0, pi / 2 + 5 * pi / 180, D / 2);
                Vector2 p14 = fun.Polar(p0, pi / 2 - 5 * pi / 180, D / 2);
                Vector2 p15 = fun.Polar(p0, pi / 2 + 5 * pi / 180, D / 2);
                Vector2 p16 = fun.Polar(p0, pi / 2 - 5 * pi / 180, D / 2);

                Vector2 p17 = fun.Polar(p0, pi / 2 + 5 * pi / 180, D / 2);
                Vector2 p18 = fun.Polar(p0, pi / 2 - 5 * pi / 180, D / 2);
                Vector2 p18_ = fun.Polar(p0, pi / -2, D / 2);
                Vector2 p19 = fun.Polar(p0, pi / 2 + 5 * pi / 180, D1 / 2);
                Vector2 p20 = fun.Polar(p0, pi / 2 - 5 * pi / 180, D1 / 2);
                Arc arc10 = fun.DrawArc(p17, p0, p18);
                // dxf.AddEntity(arc10);
                fun.drawBArc(dxf, arc10, 0.1, contour);
                */


                if (D >= 25 * scale && pd1 != 0)
                {
                    LwPolyline poly1 = new LwPolyline();
                    poly1.Vertexes.Add(new LwPolylineVertex(p42));
                    poly1.Vertexes.Add(new LwPolylineVertex(fun.Polar(p52, pi / -2, a)));
                    poly1.Vertexes.Add(new LwPolylineVertex(fun.Polar(p52, 0, a)));
                    poly1.Vertexes.Add(new LwPolylineVertex(p53));
                    poly1.Vertexes.Add(new LwPolylineVertex(p54));
                    poly1.Vertexes.Add(new LwPolylineVertex(p58));
                    poly1.Vertexes.Add(new LwPolylineVertex(p59));
                    poly1.Vertexes.Add(new LwPolylineVertex(p60));
                    poly1.Vertexes[7].Bulge = Math.Tan((105 * pi / 180) / 4);
                    poly1.Vertexes.Add(new LwPolylineVertex(p62));
                    poly1.Vertexes.Add(new LwPolylineVertex(p63));
                    poly1.Vertexes.Add(new LwPolylineVertex(p42));
                    fun.PolyFill(dxf, poly1, 0.1, contour);



                    LwPolyline poly4 = new LwPolyline();
                    poly4.Vertexes.Add(new LwPolylineVertex(p51));
                    poly4.Vertexes.Add(new LwPolylineVertex(fun.Polar(p52, pi / -2, a)));
                    poly4.Vertexes.Add(new LwPolylineVertex(fun.Polar(p52, 0, a)));
                    poly4.Vertexes.Add(new LwPolylineVertex(p53));
                    poly4.Vertexes.Add(new LwPolylineVertex(p54));
                    poly4.Vertexes.Add(new LwPolylineVertex(p55));
                    poly4.Vertexes.Add(new LwPolylineVertex(p64));
                    poly4.Vertexes.Add(new LwPolylineVertex(p66));
                    poly4.Vertexes.Add(new LwPolylineVertex(p51));
                    poly4.IsClosed = true;
                    fun.PolyFill(dxf, poly4, 0.1, contour);//将poly1这条线设置为宽度0.4的实体，contour轮廓实体。
                    String[] htype1 = new String[100];
                    Line[] hline1 = new Line[100];
                    Arc[] harc1 = new Arc[100];
                    int hnumst1 = poly4.Explode().Count;  //记录爆炸后，线段有多少
                    for (int i = 0; i < hnumst1; i++)
                    {
                        htype1[i] = poly4.Explode()[i].Type.ToString();    //将所有元素的类型记录成一个数组
                        if (htype1[i] == "Line")
                        {
                            hline1[i] = (Line)poly4.Explode()[i];
                        }
                        if (htype1[i] == "Arc")
                        {
                            harc1[i] = (Arc)poly4.Explode()[i];
                        }
                    }
                    fun.hatchsub1(dxf, htype1, hnumst1, 45, 1, hline1, harc1, hatching);
                }

                else
                {
                    LwPolyline poly1 = new LwPolyline();
                    poly1.Vertexes.Add(new LwPolylineVertex(p42));
                    poly1.Vertexes.Add(new LwPolylineVertex(p52));
                    poly1.Vertexes.Add(new LwPolylineVertex(p53));
                    poly1.Vertexes[2].Bulge = -Math.Tan((pi / 2) / 4);
                    poly1.Vertexes.Add(new LwPolylineVertex(p54));
                    poly1.Vertexes.Add(new LwPolylineVertex(p58));
                    poly1.Vertexes[4].Bulge = -Math.Tan((pi / 2) / 4);
                    poly1.Vertexes.Add(new LwPolylineVertex(p59));
                    poly1.Vertexes.Add(new LwPolylineVertex(p63));
                    poly1.Vertexes[6].Bulge = -Math.Tan((pi / 2) / 4);
                    poly1.Vertexes.Add(new LwPolylineVertex(p42));
                    fun.PolyFill(dxf, poly1, 0.1, contour);


                    LwPolyline poly4 = new LwPolyline();
                    poly4.Vertexes.Add(new LwPolylineVertex(p51));
                    poly4.Vertexes.Add(new LwPolylineVertex(p52));
                    poly4.Vertexes.Add(new LwPolylineVertex(p53));
                    poly4.Vertexes[2].Bulge = -Math.Tan((pi / 2) / 4);
                    poly4.Vertexes.Add(new LwPolylineVertex(p54));
                    poly4.Vertexes.Add(new LwPolylineVertex(p55));
                    poly4.Vertexes.Add(new LwPolylineVertex(p64));
                    poly4.Vertexes.Add(new LwPolylineVertex(p66));
                    poly4.Vertexes.Add(new LwPolylineVertex(p51));
                    poly4.IsClosed = true;
                    fun.PolyFill(dxf, poly4, 0.1, contour);//将poly1这条线设置为宽度0.4的实体，contour轮廓实体。
                    String[] htype1 = new String[100];
                    Line[] hline1 = new Line[100];
                    Arc[] harc1 = new Arc[100];
                    int hnumst1 = poly4.Explode().Count;  //记录爆炸后，线段有多少
                    for (int i = 0; i < hnumst1; i++)
                    {
                        htype1[i] = poly4.Explode()[i].Type.ToString();    //将所有元素的类型记录成一个数组
                        if (htype1[i] == "Line")
                        {
                            hline1[i] = (Line)poly4.Explode()[i];
                        }
                        if (htype1[i] == "Arc")
                        {
                            harc1[i] = (Arc)poly4.Explode()[i];
                        }
                    }
                    fun.hatchsub1(dxf, htype1, hnumst1, 45, 1, hline1, harc1, hatching);
                }
                LwPolyline poly2 = new LwPolyline();
                poly2.Vertexes.Add(new LwPolylineVertex(p51));
                poly2.Vertexes.Add(new LwPolylineVertex(p43));
                poly2.Vertexes.Add(new LwPolylineVertex(p67));
                poly2.Vertexes.Add(new LwPolylineVertex(p66));
                poly2.Vertexes.Add(new LwPolylineVertex(p51));
                fun.PolyFill(dxf, poly2, 0.1, contour);


                LwPolyline poly3 = new LwPolyline();
                poly3.Vertexes.Add(new LwPolylineVertex(p55));
                poly3.Vertexes.Add(new LwPolylineVertex(p64));
                poly3.Vertexes.Add(new LwPolylineVertex(p65));
                poly3.Vertexes.Add(new LwPolylineVertex(p57));
                poly3.Vertexes.Add(new LwPolylineVertex(p55));
                fun.PolyFill(dxf, poly3, 0.1, contour);




                LwPolyline poly5 = new LwPolyline();
                poly5.Vertexes.Add(new LwPolylineVertex(p42));
                poly5.Vertexes.Add(new LwPolylineVertex(p43));
                poly5.Vertexes.Add(new LwPolylineVertex(p67));
                poly5.Vertexes.Add(new LwPolylineVertex(p65));
                poly5.Vertexes.Add(new LwPolylineVertex(p57));
                poly5.Vertexes.Add(new LwPolylineVertex(p58));

                poly5.Vertexes.Add(new LwPolylineVertex(p59));
                poly5.Vertexes.Add(new LwPolylineVertex(p60));
                poly5.Vertexes.Add(new LwPolylineVertex(p61));
                poly5.Vertexes.Add(new LwPolylineVertex(p62));
                poly5.Vertexes.Add(new LwPolylineVertex(p63));

                poly5.Vertexes.Add(new LwPolylineVertex(p42));
                poly5.IsClosed = true;
                fun.PolyFill(dxf, poly5, 0.1, contour);//将poly1这条线设置为宽度0.4的实体，contour轮廓实体。
                String[] htype2 = new String[100];
                Line[] hline2 = new Line[100];
                Arc[] harc2 = new Arc[100];
                int hnumst2 = poly5.Explode().Count;  //记录爆炸后，线段有多少
                for (int i = 0; i < hnumst2; i++)
                {
                    htype2[i] = poly5.Explode()[i].Type.ToString();    //将所有元素的类型记录成一个数组
                    if (htype2[i] == "Line")
                    {
                        hline2[i] = (Line)poly5.Explode()[i];
                    }
                    if (htype2[i] == "Arc")
                    {
                        harc2[i] = (Arc)poly5.Explode()[i];
                    }
                }
                fun.hatchsub1(dxf, htype2, hnumst2, 45, 1, hline2, harc2, hatching);

                if (D >= 25 * scale && pd1 != 0)
                {
                }
                else
                {


                    poly5.Vertexes[5].Bulge = -Math.Tan((pi / 2) / 4);
                    poly5.Vertexes[10].Bulge = -Math.Tan((pi / 2) / 4);
                }

                LwPolyline poly6 = new LwPolyline();
                poly6.Vertexes.Add(new LwPolylineVertex(p44));
                poly6.Vertexes.Add(new LwPolylineVertex(p45));
                poly6.Vertexes.Add(new LwPolylineVertex(p71));
                poly6.Vertexes.Add(new LwPolylineVertex(p72));
                poly6.Vertexes.Add(new LwPolylineVertex(p73));
                poly6.Vertexes.Add(new LwPolylineVertex(p70));
                poly6.Vertexes.Add(new LwPolylineVertex(p69));
                poly6.Vertexes.Add(new LwPolylineVertex(p68));
                poly6.Vertexes.Add(new LwPolylineVertex(p44));
                poly6.Vertexes.Add(new LwPolylineVertex(p68));
                poly6.Vertexes.Add(new LwPolylineVertex(p71));
                poly6.Vertexes.Add(new LwPolylineVertex(p72));
                poly6.Vertexes.Add(new LwPolylineVertex(p69));
                fun.PolyFill(dxf, poly6, 0.1, contour);

                LwPolyline poly7 = new LwPolyline();
                poly7.Vertexes.Add(new LwPolylineVertex(p47));
                poly7.Vertexes.Add(new LwPolylineVertex(p48));
                poly7.Vertexes.Add(new LwPolylineVertex(p77));
                poly7.Vertexes.Add(new LwPolylineVertex(p78));
                poly7.Vertexes.Add(new LwPolylineVertex(p79));
                poly7.Vertexes.Add(new LwPolylineVertex(p76));
                poly7.Vertexes.Add(new LwPolylineVertex(p75));
                poly7.Vertexes.Add(new LwPolylineVertex(p74));
                poly7.Vertexes.Add(new LwPolylineVertex(p47));
                poly7.Vertexes.Add(new LwPolylineVertex(p74));
                poly7.Vertexes.Add(new LwPolylineVertex(p77));
                poly7.Vertexes.Add(new LwPolylineVertex(p78));
                poly7.Vertexes.Add(new LwPolylineVertex(p75));
                fun.PolyFill(dxf, poly7, 0.1, contour);

                if (D >= 25 * scale && pd1 != 0)
                {
                }
                else
                {
                    LwPolyline poly8 = new LwPolyline();
                    poly8.Vertexes.Add(new LwPolylineVertex(p49));
                    poly8.Vertexes.Add(new LwPolylineVertex(p50));
                    poly8.Vertexes.Add(new LwPolylineVertex(p83));
                    poly8.Vertexes.Add(new LwPolylineVertex(p84));
                    poly8.Vertexes.Add(new LwPolylineVertex(p85));
                    poly8.Vertexes.Add(new LwPolylineVertex(p82));
                    poly8.Vertexes.Add(new LwPolylineVertex(p81));
                    poly8.Vertexes.Add(new LwPolylineVertex(p80));
                    poly8.Vertexes.Add(new LwPolylineVertex(p49));
                    poly8.Vertexes.Add(new LwPolylineVertex(p80));
                    poly8.Vertexes.Add(new LwPolylineVertex(p83));
                    poly8.Vertexes.Add(new LwPolylineVertex(p84));
                    poly8.Vertexes.Add(new LwPolylineVertex(p81));
                    fun.PolyFill(dxf, poly8, 0.1, contour);
                }


                Line line14 = new Line(p0, p86);
                line14.Lineweight = Lineweight.W25;//Lineweight指线宽
                line14.Layer = additionalline;//Layer指图层
                line14.Linetype = Linetype.DashDot;//Linetype指是点划线还是虚线什么的
                dxf.AddEntity(line14);
                Line line15 = new Line(p86, p87);
                line15.Lineweight = Lineweight.W25;//Lineweight指线宽              
                dxf.AddEntity(line15);
                Line line16 = new Line(p87, p88);
                line16.Lineweight = Lineweight.W25;//Lineweight指线宽               
                dxf.AddEntity(line16);

                Solid entity1 = new Solid(p89, p90, p91);
                dxf.AddEntity(entity1);



                Line line17 = new Line(p0, p92);
                line17.Lineweight = Lineweight.W25;//Lineweight指线宽
                line17.Layer = additionalline;//Layer指图层
                line17.Linetype = Linetype.DashDot;//Linetype指是点划线还是虚线什么的
                dxf.AddEntity(line17);
                Line line18 = new Line(p92, p93);
                line18.Lineweight = Lineweight.W25;//Lineweight指线宽              
                dxf.AddEntity(line18);
                Line line19 = new Line(p93, p94);
                line19.Lineweight = Lineweight.W25;//Lineweight指线宽               
                dxf.AddEntity(line19);
                Solid entity2 = new Solid(p95, p96, p97);
                dxf.AddEntity(entity2);

                //标注

                DimensionStyle dimensionStyle = new DimensionStyle("sd");
                dimensionStyle.ArrowSize = 1.6;
                dimensionStyle.DimArrow1 = DimensionArrowhead.Closedfilled;
                dimensionStyle.DimArrow2 = DimensionArrowhead.Closedfilled;
                dimensionStyle.TextHeight = 1.2;
                double offset = D;




                fun.dimrot1(dxf, p0, p37, 45, D - 2, 2, 1.6, 1.2, 0.9, "c=" + c, "", "");
                fun.dimrot1(dxf, p0, p34, -45, D - 2, 2, 1.6, 1.2, 0.9, "c=" + c, "", "");
                fun.dimrot1(dxf, p52, p54, 0, E * 2, 2, 1.6, 1.2, 0.9, "E=" + E, "", "");
                fun.dimrot1(dxf, p51, p64, 0, E, 2, 1.6, 1.2, 0.9, "E1=" + E1, "", "");
                fun.dimrot1(dxf, p55, p57, -90, E, 2, 1.6, 1.2, 0.9, "D1=" + D1, "", "");
                fun.dimrot1(dxf, p53, p59, -90, E * 2, 2, 1.6, 1.2, 0.9, "D=" + D, "", "");
                //  fun.dimrot1(dxf, p42, p63, 180, E, 2, 1.6, 1.2, 0.9, "a×45", "", "");
                // fun.dimrot1(dxf, p59, p58, 180, E, 2, 1.6, 1.2, 0.9, "a×45", "", "");
                LinearDimension dim2 = new LinearDimension(new Line(p42, p63), offset, 180, dimensionStyle);
                dim2.UserText = "a×45";
                dxf.AddEntity(dim2);
                LinearDimension dim3 = new LinearDimension(new Line(p59, p58), offset, 180, dimensionStyle);
                dim3.UserText = "a×45";
                dxf.AddEntity(dim3);

                fun.dimrot1(dxf, p62, p60, 180, D / 2.0, 2, 1.6, 1.2, 0.9, "b=" + b, "", "");
                fun.dimrot1(dxf, p42, p61, 180, D + 8, 2, 1.6, 1.2, 0.9, "0.5E", "", "");



                fun.jdbz2(dxf, new Line(p0, fun.Polar(p0, pi / 2, 0.1)), new Line(p0, fun.Polar(p0, pi / 2 + pi / 4, 0.1)), D, 1.6, 1.2, 0.9, "45" + "°", "0", "0");
                fun.jdbz2(dxf, new Line(p0, fun.Polar(p0, pi / 2 - pi / 4, 0.1)), new Line(p0, fun.Polar(p0, pi / 2, 0.1)), D, 1.6, 1.2, 0.9, "45" + "°", "0", "0");
                // fun.jdbz2(dxf, new Line(p30, p28), new Line(p30, p29), D, 1.6, 1.2, 0.9, "90" + "°", "0", "0");
                Angular2LineDimension dim4 = new Angular2LineDimension(new Line(p30, p28), new Line(p30, p29), offset, dimensionStyle);
                dim4.UserText = "90" + "°";
                dxf.AddEntity(dim4);




            }

            double isframe = Convert.ToInt32(data["isframe"]);
            String isframe_chose = Convert.ToString(data["isframe_chose"]);

            if (isframe == 1)
            {
                Vector2 p0 = new Vector2(0, 0);
                if (isframe_chose.Equals("0"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA0X(dxf, new Vector2(p0.X - 1189 / 2.0, p0.Y + 841 / 2.0), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }

                if (isframe_chose.Equals("1"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA1X(dxf, new Vector2(p0.X - 841 / 2.0, p0.Y + 594 / 2.0), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }

                if (isframe_chose.Equals("2"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA2X(dxf, new Vector2(p0.X - 594 / 2.0, p0.Y + 420 / 2.0), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }

                if (isframe_chose.Equals("3"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA3X(dxf, new Vector2(p0.X - 420 / 2.0, p0.Y + 297 / 2.0), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }

                if (isframe_chose.Equals("4X"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA4X(dxf, new Vector2(p0.X - 297 / 2.0, p0.Y + 210 / 2.0 - 10 * 2.26), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }

                if (isframe_chose.Equals("4Y"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA4Y(dxf, new Vector2(p0.X - 210 / 2.0, p0.Y + 297 / 2.0), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }
            }






            fun.SetLayer(dxf);
            fun.SetByLayer(dxf);

            dxf.DrawingVariables.AcadVer = DxfVersion.AutoCad2007;
            dxf.Save(path);
        }


        public static void Rthreadcircularplatethread(Dictionary<string, Object> data)  //r圆板牙
        {
            DxfDocument dxf = new DxfDocument();
            dxf.Layers["0"].Lineweight = Lineweight.W25;
            Layer contour = new Layer("contour");//轮廓层
            Layer dimensioning = new Layer("dimensioning");//尺寸层
            Layer refin = new Layer("refin");//基准线/内轮廓/虚线
            Layer center = new Layer("center");//中心线
            Layer textlayer = new Layer("textlayer");//文本层
            Layer hatching = new Layer("hatching");//填充层
            Layer additionalline = new Layer("additionalline");//附加线
            Layer cutting = new Layer("cutting");//切削层
            fun.SetLayer(dxf);

            double pi = Math.PI;
            string path = Convert.ToString(data["path"]);


            /*
            double d = 7.0;
            double P = 1.0;
            double d1 = d - (P * 1.0825);//小径
            double b = 5.0;
            double D = 30;
            double D1 = 24;
            double DD1 = 0;
            double E = 8.0;
            double E1 = 0;
            double c = 0.8;
            double a = 0.5;
            double pxk = 6;//排泄孔
            double px = pi - pi /4/4;
            */

            double d = Convert.ToDouble(data["td"]);
            double P = Convert.ToDouble(data["tp"]);
            double d1 = d - (P * 1.0825);//小径
            double b = Convert.ToDouble(data["b"]);
            double D = Convert.ToDouble(data["bd"]);
            double D1 = Convert.ToDouble(data["d1"]);
            double DD1 = Convert.ToDouble(data["dd1"]);
            double E = Convert.ToDouble(data["oal"]);
            double E1 = Convert.ToDouble(data["e1"]);
            double c = Convert.ToDouble(data["c"]);
            double a = Convert.ToDouble(data["a"]);
            double pxk = Convert.ToDouble(data["pxk"]);//排泄孔
            double px = pi - pi / 4 / 4;
            double pd = d % 1;
            double pd1 = (pd * 10.0) % 1;
            /*
            double d = 7.723;
            double P = 0.907;
            double d1 = d - (P * 1.0825);//小径
            double b = 5;
            double D = 25;
            double D1 = 0;
            double DD1 = 0;
            double E = 11;
            double E1 = 0;
            double c = 1;
            double a = 1;
            double pxk = 6;//排泄孔
            double px = pi - pi / 4 / 4;

            double pd = d % 1;
            double pd1 = (pd * 10.0) % 1;
            */
            if (pxk == 0)
            {
                pxk = DD1 / 2 - d1 / 2.0 + 0.01;

            }

            if (D >= 25 && pd1 != 0)
            {
                px = pi / 2 + pi / 4 / 4;

            }
            else
            {
                px = pi - pi / 4 / 4;
            }



            if (D >= 25 && pd1 != 0)
            {
                E1 = E;
                D1 = D - b;
                DD1 = D1;
            }



            double ang1 = Math.Acos(((d1 / 2.0 * d1 / 2.0) + ((d1 / 2 - 0.1 + pxk / 2.0) * (d1 / 2 - 0.1 + pxk / 2.0)) - (pxk / 2.0 * pxk / 2.0)) / (2 * d1 / 2.0 * (d1 / 2 - 0.1 + pxk / 2.0)));

            double ang2 = Math.Acos(((d / 2.0 * d / 2.0) + ((d1 / 2 - 0.1 + pxk / 2.0) * (d1 / 2 - 0.1 + pxk / 2.0)) - (pxk / 2.0 * pxk / 2.0)) / (2 * d / 2.0 * (d1 / 2 - 0.1 + pxk / 2.0)));



            Vector2 zx1 = new Vector2(0, D / 2 + 5);
            Vector2 zx2 = new Vector2(0, D / -2 - 5);
            Vector2 zx3 = new Vector2(D / 2 + 5, 0);
            Vector2 zx4 = new Vector2(D / -2 - 5, 0);


            Vector2 p0 = new Vector2(0, 0);
            Vector2 p1p = fun.Polar(p0, pi / 2, d1 / 2 - 0.1 + pxk / 2.0);
            Vector2 p2p = fun.PointRotate(p0, p1p, (pi * 2.0 / 5.0));
            Vector2 p3p = fun.PointRotate(p0, p1p, (pi * 2.0 / 5.0) * 2);
            Vector2 p4p = fun.PointRotate(p0, p1p, (pi * 2.0 / 5.0) * 3);
            Vector2 p5p = fun.PointRotate(p0, p1p, (pi * 2.0 / 5.0) * 4);
            Vector2 p6p = fun.PointRotate(p0, p1p, (pi * 2.0 / 5.0) * 5);

            Vector2 p1 = fun.Polar(p0, pi / 2 + ang1, d1 / 2.0);
            Vector2 p2 = fun.Polar(p0, pi / 2 + ang2, d / 2.0);
            Vector2 p3 = fun.Polar(p0, pi / 2 - ang1, d1 / 2.0);
            Vector2 p4 = fun.Polar(p0, pi / 2 - ang2, d / 2.0);

            Vector2 p5 = fun.PointRotate(p0, p1, (pi * 2.0 / 5.0));
            Vector2 p6 = fun.PointRotate(p0, p2, (pi * 2.0 / 5.0));
            Vector2 p7 = fun.PointRotate(p0, p3, (pi * 2.0 / 5.0));
            Vector2 p8 = fun.PointRotate(p0, p4, (pi * 2.0 / 5.0));

            Vector2 p9 = fun.PointRotate(p0, p1, (pi * 2.0 / 5.0) * 2);
            Vector2 p10 = fun.PointRotate(p0, p2, (pi * 2.0 / 5.0) * 2);
            Vector2 p11 = fun.PointRotate(p0, p3, (pi * 2.0 / 5.0) * 2);
            Vector2 p12 = fun.PointRotate(p0, p4, (pi * 2.0 / 5.0) * 2);

            Vector2 p13 = fun.PointRotate(p0, p1, (pi * 2.0 / 5.0) * 3);
            Vector2 p14 = fun.PointRotate(p0, p2, (pi * 2.0 / 5.0) * 3);
            Vector2 p15 = fun.PointRotate(p0, p3, (pi * 2.0 / 5.0) * 3);
            Vector2 p16 = fun.PointRotate(p0, p4, (pi * 2.0 / 5.0) * 3);

            Vector2 p17 = fun.PointRotate(p0, p1, (pi * 2.0 / 5.0) * 4);
            Vector2 p18 = fun.PointRotate(p0, p2, (pi * 2.0 / 5.0) * 4);
            Vector2 p19 = fun.PointRotate(p0, p3, (pi * 2.0 / 5.0) * 4);
            Vector2 p20 = fun.PointRotate(p0, p4, (pi * 2.0 / 5.0) * 4);
            //卡槽
            Vector2 p21 = fun.Polar(p0, pi / 2 + 5 * pi / 180, D / 2);
            Vector2 p22 = fun.Polar(p0, pi / 2 + 5 * pi / 180, D1 / 2);
            Vector2 p23 = fun.Polar(p0, pi / 2 + 5 * pi / 180, DD1 / 2);

            Vector2 p24 = fun.Polar(p0, pi / 2 - 5 * pi / 180, D / 2);
            Vector2 p24_ = fun.Polar(p0, pi / -2, D / 2);
            Vector2 p25 = fun.Polar(p0, pi / 2 - 5 * pi / 180, D1 / 2);
            Vector2 p26 = fun.Polar(p0, pi / 2 - 5 * pi / 180, DD1 / 2);
            Arc arc18 = fun.DrawArc(p21, p0, p24_);
            // dxf.AddEntity(arc10);
            fun.drawBArc(dxf, arc18, 0.1, contour);
            Arc arc19 = fun.DrawArc(p24_, p0, p24);
            // dxf.AddEntity(arc19);
            fun.drawBArc(dxf, arc19, 0.1, contour);

            //四个槽孔
            Vector2 p27 = fun.Polar(p0, pi / -4, Math.Sqrt(((D / 2) * (D / 2)) - (b / 2) * (b / 2)));
            Vector2 p28 = fun.Polar(p27, pi + pi / 4, b / 2);
            Vector2 p29 = fun.Polar(p27, pi / 4, b / 2);
            Vector2 p30 = fun.Polar(p27, pi / 2 + pi / 4, b / 2);
            Vector2 p31 = fun.PointRotate(p0, p30, (pi / 2));
            Vector2 p32_ = fun.Polar(p31, pi, 50);
            Vector2 p32 = fun.Inters1(p31, p32_, arc18, 2);
            Vector2 p33 = fun.Polar(p32, pi / -4, b);
            Vector2 p34_ = fun.PointRotate(p0, p30, (pi / -2));
            Vector2 p34 = fun.Polar(p34_, pi / -4, c);
            Vector2 p35_ = new Vector2(p34.X, p34.Y + 10);


            Vector2 p35 = fun.Inters1(p34, p35_, arc19, 1);
            Vector2 p36_ = fun.Polar(p34, 0, 50);
            Vector2 p36 = fun.Inters1(p34, p36_, arc19, 1);
            Vector2 p37 = fun.mirrorpoint(p34, zx1, zx2);
            Vector2 p38 = fun.mirrorpoint(p35, zx1, zx2);
            Vector2 p39 = fun.mirrorpoint(p36, zx1, zx2);

            Vector2 p40 = fun.Polar(p0, pi / -2, D / 2);
            Vector2 p41 = fun.Polar(p40, 0, D * 2);
            Vector2 p42 = fun.Polar(p41, pi / 2, a);
            Vector2 p43 = fun.Polar(p41, pi / 2, D / 2 - DD1 / 2);
            Vector2 p44 = fun.Polar(p43, pi / 2, DD1 / 4);
            Vector2 p45 = fun.Polar(p44, pi / 2, (d - d1) / 2.0);
            Vector2 p46 = fun.Polar(p43, pi / 2, DD1 / 2);
            Vector2 p47 = fun.Polar(p46, pi / 2, (DD1 / 2.0 / 3.0));
            Vector2 p48 = fun.Polar(p47, pi / 2, (d - d1) / 2.0);
            Vector2 p49 = fun.Polar(p47, pi / 2, (DD1 / 2.0 / 3.0));
            Vector2 p50 = fun.Polar(p49, pi / 2, (d - d1) / 2.0);
            Vector2 p51 = fun.Polar(p43, pi / 2, DD1);
            Vector2 p52 = fun.Polar(p41, pi / 2, D);
            Vector2 p53 = fun.Polar(p52, 0, E - a);
            Vector2 p54 = fun.Polar(p53, pi / -4, Math.Sqrt(2) * a);
            Vector2 p55 = fun.Polar(p54, pi / -2, (D / 2.0) - (D1 / 2.0) - a);
            Vector2 p56 = fun.Polar(p46, 0, E);
            Vector2 p57 = fun.Polar(p55, pi / -2, D1);
            Vector2 p58 = fun.Polar(p57, pi / -2, (D / 2.0) - (D1 / 2.0) - a);
            Vector2 p59 = fun.Polar(p58, pi / -2 + pi / -4, Math.Sqrt(2) * a);
            Vector2 p60 = fun.Polar(p59, pi, E / 2.0 - a - b / 2);
            Vector2 p61 = fun.Polar(p60, pi - pi / 4, b / (Math.Sqrt(2)));
            Vector2 p62 = fun.Polar(p61, pi + pi / 4, b / (Math.Sqrt(2)));
            Vector2 p63 = fun.Polar(p62, pi, E / 2.0 - b / 2.0 - a);
            Vector2 p64 = fun.Polar(p55, pi, E - E1);
            Vector2 p65 = fun.Polar(p57, pi, E - E1);
            Vector2 p66 = fun.Polar(p51, 0, E1);
            Vector2 p67 = fun.Polar(p43, 0, E1);

            Vector2 p68;
            Vector2 p69;
            Vector2 p70;
            Vector2 p71;
            Vector2 p72;
            Vector2 p73;
            Vector2 p74;
            Vector2 p75;
            Vector2 p76;
            Vector2 p77;
            Vector2 p78;
            Vector2 p79;
            Vector2 p80;
            Vector2 p81;
            Vector2 p82;
            Vector2 p83;
            Vector2 p84;


            if (D >= 25 && pd1 != 0)
            {
                p68 = fun.Polar(p44, pi / 4, Math.Sqrt(2) * (E1 / 10.0));
                p69 = fun.Polar(p68, 10 * pi / 180, (E1 - (E1 / 10.0)) / Math.Cos(10 * pi / 180));
                p70 = fun.Polar(p44, 0, E1);
                p71 = fun.Polar(p68, pi / 2, (d - d1) / 2.0);
                p72 = fun.Polar(p69, pi / 2, (d - d1) / 2.0);
                p73 = fun.Polar(p45, 0, E1);
                p74 = fun.Polar(p47, pi / -4, Math.Sqrt(2) * (E1 / 10.0));
                p75 = fun.Polar(p74, -10 * pi / 180, (E1 - (E1 / 10.0)) / Math.Cos(10 * pi / 180));
                p76 = fun.Polar(p47, 0, E1);
                p77 = fun.Polar(p74, pi / 2, (d - d1) / 2.0);
                p78 = fun.Polar(p75, pi / 2, (d - d1) / 2.0);
                p79 = fun.Polar(p48, 0, E1);
                p80 = fun.Polar(p49, pi / -4, Math.Sqrt(2) * (E1 / 10.0));
                p81 = fun.Polar(p80, -10 * pi / 180, (E1 - (E1 / 10.0)) / Math.Cos(10 * pi / 180));
                p82 = fun.Polar(p49, 0, E1);
                p83 = fun.Polar(p80, pi / 2, (d - d1) / 2.0);
                p84 = fun.Polar(p81, pi / 2, (d - d1) / 2.0);

            }


            else
            {
                p68 = fun.Polar(p44, pi / 4, Math.Sqrt(2) * (E1 / 3.0));
                p69 = fun.Polar(p68, 0, E1 / 3.0);
                p70 = fun.Polar(p44, 0, E1);
                p71 = fun.Polar(p68, pi / 2, (d - d1) / 2.0);
                p72 = fun.Polar(p69, pi / 2, (d - d1) / 2.0);
                p73 = fun.Polar(p45, 0, E1);
                p74 = fun.Polar(p47, pi / -4, Math.Sqrt(2) * (E1 / 3.0));
                p75 = fun.Polar(p74, 0, E1 / 3.0);
                p76 = fun.Polar(p47, 0, E1);
                p77 = fun.Polar(p74, pi / 2, (d - d1) / 2.0);
                p78 = fun.Polar(p75, pi / 2, (d - d1) / 2.0);
                p79 = fun.Polar(p48, 0, E1);
                p80 = fun.Polar(p49, pi / -4, Math.Sqrt(2) * (E1 / 3.0));
                p81 = fun.Polar(p80, 0, E1 / 3.0);
                p82 = fun.Polar(p49, 0, E1);
                p83 = fun.Polar(p80, pi / 2, (d - d1) / 2.0);
                p84 = fun.Polar(p81, pi / 2, (d - d1) / 2.0);
            }
            Vector2 p85 = fun.Polar(p50, 0, E1);
            //刨线
            Vector2 p86 = fun.Polar(p0, px, D / 2 + 4);
            Vector2 p87 = fun.Polar(p86, px, 4);
            Vector2 p88 = fun.Polar(p87, px - pi / 2, 4);
            Vector2 p89 = fun.Polar(p88, px, 1.2 * Math.Tan(10 * pi / 180));
            Vector2 p90 = fun.Polar(p88, px - pi, 1.2 * Math.Tan(10 * pi / 180));
            Vector2 p91 = fun.Polar(p88, px - pi / 2, 1.2);
            Vector2 p92 = fun.Polar(p0, pi / -4, D / 2 + 4);
            Vector2 p93 = fun.Polar(p92, pi / -4, 4);
            Vector2 p94 = fun.Polar(p93, pi / -4 + pi / 2, 4);
            Vector2 p95 = fun.Polar(p94, pi / -4 - pi, 1.2 * Math.Tan(10 * pi / 180));
            Vector2 p96 = fun.Polar(p94, pi / -4, 1.2 * Math.Tan(10 * pi / 180));
            Vector2 p97 = fun.Polar(p94, pi / -4 + pi / 2, 1.2);


            Vector2 zx5 = fun.Polar(p46, pi, 4);
            Vector2 zx6 = fun.Polar(p56, 0, 4);




            Line line3 = new Line(p28, p30);
            fun.drawBline(dxf, line3, 0.1, contour);
            Line line4 = new Line(p29, p30);
            fun.drawBline(dxf, line4, 0.1, contour);
            Line line5 = new Line(p32, p31);
            fun.drawBline(dxf, line5, 0.1, contour);
            Line line6 = new Line(p33, p31);
            fun.drawBline(dxf, line6, 0.1, contour);
            Line line7 = new Line(p34, p36);
            fun.drawBline(dxf, line7, 0.1, contour);
            Line line8 = new Line(p34, p35);
            fun.drawBline(dxf, line8, 0.1, contour);
            Line line9 = new Line(p37, p39);
            fun.drawBline(dxf, line9, 0.1, contour);
            Line line10 = new Line(p37, p38);
            fun.drawBline(dxf, line10, 0.1, contour);



            Arc arc1 = fun.DrawArc(p3, p1p, p1);
            fun.drawBArc(dxf, arc1, 0.1, contour);
            Arc arc2 = fun.DrawArc(p7, p2p, p5);
            fun.drawBArc(dxf, arc2, 0.1, contour);
            Arc arc3 = fun.DrawArc(p11, p3p, p9);
            fun.drawBArc(dxf, arc3, 0.1, contour);
            Arc arc4 = fun.DrawArc(p15, p4p, p13);
            fun.drawBArc(dxf, arc4, 0.1, contour);
            Arc arc5 = fun.DrawArc(p19, p5p, p17);
            fun.drawBArc(dxf, arc5, 0.1, contour);
            Arc arc6 = fun.DrawArc(p6, p0, p4);
            fun.drawBArc(dxf, arc6, 0.1, contour);
            Arc arc7 = fun.DrawArc(p5, p0, p3);
            fun.drawBArc(dxf, arc7, 0.1, contour);
            Arc arc8 = fun.DrawArc(p10, p0, p8);
            fun.drawBArc(dxf, arc8, 0.1, contour);
            Arc arc9 = fun.DrawArc(p9, p0, p7);
            fun.drawBArc(dxf, arc9, 0.1, contour);
            Arc arc10 = fun.DrawArc(p14, p0, p12);
            fun.drawBArc(dxf, arc10, 0.1, contour);
            Arc arc11 = fun.DrawArc(p13, p0, p11);
            fun.drawBArc(dxf, arc11, 0.1, contour);
            Arc arc12 = fun.DrawArc(p18, p0, p16);
            fun.drawBArc(dxf, arc12, 0.1, contour);
            Arc arc13 = fun.DrawArc(p17, p0, p15);
            fun.drawBArc(dxf, arc13, 0.1, contour);
            Arc arc14 = fun.DrawArc(p2, p0, p20);
            fun.drawBArc(dxf, arc14, 0.1, contour);
            Arc arc15 = fun.DrawArc(p1, p0, p19);
            fun.drawBArc(dxf, arc15, 0.1, contour);

            Arc arc16 = fun.DrawArc(p21, p0, p24);
            fun.drawBArc(dxf, arc16, 0.1, contour);
            Arc arc17 = fun.DrawArc(p22, p0, p25);
            fun.drawBArc(dxf, arc17, 0.1, contour);






            Circle circle1 = new Circle(new Vector3(0, 0, 0), DD1 / 2);
            //dxf.AddEntity(circle1);
            fun.drawcircle(dxf, p0, DD1 / 2, 0.1, contour);

            Line line1 = new Line(p21, p23);
            Line line2 = new Line(p24, p26);
            fun.drawBline(dxf, line1, 0.1, contour);
            fun.drawBline(dxf, line2, 0.1, contour);



            //中心线

            Line line11 = new Line(zx1, zx2);
            line11.Lineweight = Lineweight.W25;//Lineweight指线宽
            line11.Layer = center;//Layer指图层
            line11.Linetype = Linetype.DashDot;//Linetype指是点划线还是虚线什么的
            dxf.AddEntity(line11);

            Line line12 = new Line(zx3, zx4);
            line12.Lineweight = Lineweight.W25;//Lineweight指线宽
            line12.Layer = center;//Layer指图层
            line12.Linetype = Linetype.DashDot;//Linetype指是点划线还是虚线什么的
            dxf.AddEntity(line12);

            Line line13 = new Line(zx5, zx6);
            line13.Lineweight = Lineweight.W25;//Lineweight指线宽
            line13.Layer = center;//Layer指图层
            line13.Linetype = Linetype.DashDot;//Linetype指是点划线还是虚线什么的
            dxf.AddEntity(line13);

            /*
            Vector2 p13 = fun.Polar(p0, pi / 2 + 5 * pi / 180, D / 2);
            Vector2 p14 = fun.Polar(p0, pi / 2 - 5 * pi / 180, D / 2);
            Vector2 p15 = fun.Polar(p0, pi / 2 + 5 * pi / 180, D / 2);
            Vector2 p16 = fun.Polar(p0, pi / 2 - 5 * pi / 180, D / 2);

            Vector2 p17 = fun.Polar(p0, pi / 2 + 5 * pi / 180, D / 2);
            Vector2 p18 = fun.Polar(p0, pi / 2 - 5 * pi / 180, D / 2);
            Vector2 p18_ = fun.Polar(p0, pi / -2, D / 2);
            Vector2 p19 = fun.Polar(p0, pi / 2 + 5 * pi / 180, D1 / 2);
            Vector2 p20 = fun.Polar(p0, pi / 2 - 5 * pi / 180, D1 / 2);
            Arc arc10 = fun.DrawArc(p17, p0, p18);
            // dxf.AddEntity(arc10);
            fun.drawBArc(dxf, arc10, 0.1, contour);
            */


            if (D >= 25 && pd1 != 0)
            {
                LwPolyline poly1 = new LwPolyline();
                poly1.Vertexes.Add(new LwPolylineVertex(p42));
                poly1.Vertexes.Add(new LwPolylineVertex(fun.Polar(p52, pi / -2, a)));
                poly1.Vertexes.Add(new LwPolylineVertex(fun.Polar(p52, 0, a)));
                poly1.Vertexes.Add(new LwPolylineVertex(p53));
                poly1.Vertexes.Add(new LwPolylineVertex(p54));
                poly1.Vertexes.Add(new LwPolylineVertex(p58));
                poly1.Vertexes.Add(new LwPolylineVertex(p59));
                poly1.Vertexes.Add(new LwPolylineVertex(p60));
                poly1.Vertexes[7].Bulge = Math.Tan((105 * pi / 180) / 4);
                poly1.Vertexes.Add(new LwPolylineVertex(p62));
                poly1.Vertexes.Add(new LwPolylineVertex(p63));
                poly1.Vertexes.Add(new LwPolylineVertex(p42));
                fun.PolyFill(dxf, poly1, 0.1, contour);



                LwPolyline poly4 = new LwPolyline();
                poly4.Vertexes.Add(new LwPolylineVertex(p51));
                poly4.Vertexes.Add(new LwPolylineVertex(fun.Polar(p52, pi / -2, a)));
                poly4.Vertexes.Add(new LwPolylineVertex(fun.Polar(p52, 0, a)));
                poly4.Vertexes.Add(new LwPolylineVertex(p53));
                poly4.Vertexes.Add(new LwPolylineVertex(p54));
                poly4.Vertexes.Add(new LwPolylineVertex(p55));
                poly4.Vertexes.Add(new LwPolylineVertex(p64));
                poly4.Vertexes.Add(new LwPolylineVertex(p66));
                poly4.Vertexes.Add(new LwPolylineVertex(p51));
                poly4.IsClosed = true;
                fun.PolyFill(dxf, poly4, 0.1, contour);//将poly1这条线设置为宽度0.4的实体，contour轮廓实体。
                String[] htype1 = new String[100];
                Line[] hline1 = new Line[100];
                Arc[] harc1 = new Arc[100];
                int hnumst1 = poly4.Explode().Count;  //记录爆炸后，线段有多少
                for (int i = 0; i < hnumst1; i++)
                {
                    htype1[i] = poly4.Explode()[i].Type.ToString();    //将所有元素的类型记录成一个数组
                    if (htype1[i] == "Line")
                    {
                        hline1[i] = (Line)poly4.Explode()[i];
                    }
                    if (htype1[i] == "Arc")
                    {
                        harc1[i] = (Arc)poly4.Explode()[i];
                    }
                }
                fun.hatchsub1(dxf, htype1, hnumst1, 45, 1, hline1, harc1, hatching);
            }

            else
            {
                LwPolyline poly1 = new LwPolyline();
                poly1.Vertexes.Add(new LwPolylineVertex(p42));
                poly1.Vertexes.Add(new LwPolylineVertex(p52));
                poly1.Vertexes.Add(new LwPolylineVertex(p53));
                poly1.Vertexes[2].Bulge = -Math.Tan((pi / 2) / 4);
                poly1.Vertexes.Add(new LwPolylineVertex(p54));
                poly1.Vertexes.Add(new LwPolylineVertex(p58));
                poly1.Vertexes[4].Bulge = -Math.Tan((pi / 2) / 4);
                poly1.Vertexes.Add(new LwPolylineVertex(p59));
                poly1.Vertexes.Add(new LwPolylineVertex(p63));
                poly1.Vertexes[6].Bulge = -Math.Tan((pi / 2) / 4);
                poly1.Vertexes.Add(new LwPolylineVertex(p42));
                fun.PolyFill(dxf, poly1, 0.1, contour);


                LwPolyline poly4 = new LwPolyline();
                poly4.Vertexes.Add(new LwPolylineVertex(p51));
                poly4.Vertexes.Add(new LwPolylineVertex(p52));
                poly4.Vertexes.Add(new LwPolylineVertex(p53));
                poly4.Vertexes[2].Bulge = -Math.Tan((pi / 2) / 4);
                poly4.Vertexes.Add(new LwPolylineVertex(p54));
                poly4.Vertexes.Add(new LwPolylineVertex(p55));
                poly4.Vertexes.Add(new LwPolylineVertex(p64));
                poly4.Vertexes.Add(new LwPolylineVertex(p66));
                poly4.Vertexes.Add(new LwPolylineVertex(p51));
                poly4.IsClosed = true;
                fun.PolyFill(dxf, poly4, 0.1, contour);//将poly1这条线设置为宽度0.4的实体，contour轮廓实体。
                String[] htype1 = new String[100];
                Line[] hline1 = new Line[100];
                Arc[] harc1 = new Arc[100];
                int hnumst1 = poly4.Explode().Count;  //记录爆炸后，线段有多少
                for (int i = 0; i < hnumst1; i++)
                {
                    htype1[i] = poly4.Explode()[i].Type.ToString();    //将所有元素的类型记录成一个数组
                    if (htype1[i] == "Line")
                    {
                        hline1[i] = (Line)poly4.Explode()[i];
                    }
                    if (htype1[i] == "Arc")
                    {
                        harc1[i] = (Arc)poly4.Explode()[i];
                    }
                }
                fun.hatchsub1(dxf, htype1, hnumst1, 45, 1, hline1, harc1, hatching);
            }
            LwPolyline poly2 = new LwPolyline();
            poly2.Vertexes.Add(new LwPolylineVertex(p51));
            poly2.Vertexes.Add(new LwPolylineVertex(p43));
            poly2.Vertexes.Add(new LwPolylineVertex(p67));
            poly2.Vertexes.Add(new LwPolylineVertex(p66));
            poly2.Vertexes.Add(new LwPolylineVertex(p51));
            fun.PolyFill(dxf, poly2, 0.1, contour);


            LwPolyline poly3 = new LwPolyline();
            poly3.Vertexes.Add(new LwPolylineVertex(p55));
            poly3.Vertexes.Add(new LwPolylineVertex(p64));
            poly3.Vertexes.Add(new LwPolylineVertex(p65));
            poly3.Vertexes.Add(new LwPolylineVertex(p57));
            poly3.Vertexes.Add(new LwPolylineVertex(p55));
            fun.PolyFill(dxf, poly3, 0.1, contour);




            LwPolyline poly5 = new LwPolyline();
            poly5.Vertexes.Add(new LwPolylineVertex(p42));
            poly5.Vertexes.Add(new LwPolylineVertex(p43));
            poly5.Vertexes.Add(new LwPolylineVertex(p67));
            poly5.Vertexes.Add(new LwPolylineVertex(p65));
            poly5.Vertexes.Add(new LwPolylineVertex(p57));
            poly5.Vertexes.Add(new LwPolylineVertex(p58));

            poly5.Vertexes.Add(new LwPolylineVertex(p59));
            poly5.Vertexes.Add(new LwPolylineVertex(p60));
            poly5.Vertexes.Add(new LwPolylineVertex(p61));
            poly5.Vertexes.Add(new LwPolylineVertex(p62));
            poly5.Vertexes.Add(new LwPolylineVertex(p63));

            poly5.Vertexes.Add(new LwPolylineVertex(p42));
            poly5.IsClosed = true;
            fun.PolyFill(dxf, poly5, 0.1, contour);//将poly1这条线设置为宽度0.4的实体，contour轮廓实体。
            String[] htype2 = new String[100];
            Line[] hline2 = new Line[100];
            Arc[] harc2 = new Arc[100];
            int hnumst2 = poly5.Explode().Count;  //记录爆炸后，线段有多少
            for (int i = 0; i < hnumst2; i++)
            {
                htype2[i] = poly5.Explode()[i].Type.ToString();    //将所有元素的类型记录成一个数组
                if (htype2[i] == "Line")
                {
                    hline2[i] = (Line)poly5.Explode()[i];
                }
                if (htype2[i] == "Arc")
                {
                    harc2[i] = (Arc)poly5.Explode()[i];
                }
            }
            fun.hatchsub1(dxf, htype2, hnumst2, 45, 1, hline2, harc2, hatching);

            if (D >= 25 && pd1 != 0)
            {
            }
            else
            {


                poly5.Vertexes[5].Bulge = -Math.Tan((pi / 2) / 4);
                poly5.Vertexes[10].Bulge = -Math.Tan((pi / 2) / 4);
            }

            LwPolyline poly6 = new LwPolyline();
            poly6.Vertexes.Add(new LwPolylineVertex(p44));
            poly6.Vertexes.Add(new LwPolylineVertex(p45));
            poly6.Vertexes.Add(new LwPolylineVertex(p71));
            poly6.Vertexes.Add(new LwPolylineVertex(p72));
            poly6.Vertexes.Add(new LwPolylineVertex(p73));
            poly6.Vertexes.Add(new LwPolylineVertex(p70));
            poly6.Vertexes.Add(new LwPolylineVertex(p69));
            poly6.Vertexes.Add(new LwPolylineVertex(p68));
            poly6.Vertexes.Add(new LwPolylineVertex(p44));
            poly6.Vertexes.Add(new LwPolylineVertex(p68));
            poly6.Vertexes.Add(new LwPolylineVertex(p71));
            poly6.Vertexes.Add(new LwPolylineVertex(p72));
            poly6.Vertexes.Add(new LwPolylineVertex(p69));
            fun.PolyFill(dxf, poly6, 0.1, contour);



            if (D >= 25 && pd1 != 0)
            {
            }
            else
            {
                LwPolyline poly7 = new LwPolyline();
                poly7.Vertexes.Add(new LwPolylineVertex(p47));
                poly7.Vertexes.Add(new LwPolylineVertex(p48));
                poly7.Vertexes.Add(new LwPolylineVertex(p77));
                poly7.Vertexes.Add(new LwPolylineVertex(p78));
                poly7.Vertexes.Add(new LwPolylineVertex(p79));
                poly7.Vertexes.Add(new LwPolylineVertex(p76));
                poly7.Vertexes.Add(new LwPolylineVertex(p75));
                poly7.Vertexes.Add(new LwPolylineVertex(p74));
                poly7.Vertexes.Add(new LwPolylineVertex(p47));
                poly7.Vertexes.Add(new LwPolylineVertex(p74));
                poly7.Vertexes.Add(new LwPolylineVertex(p77));
                poly7.Vertexes.Add(new LwPolylineVertex(p78));
                poly7.Vertexes.Add(new LwPolylineVertex(p75));
                fun.PolyFill(dxf, poly7, 0.1, contour);
            }
            LwPolyline poly8 = new LwPolyline();
            poly8.Vertexes.Add(new LwPolylineVertex(p49));
            poly8.Vertexes.Add(new LwPolylineVertex(p50));
            poly8.Vertexes.Add(new LwPolylineVertex(p83));
            poly8.Vertexes.Add(new LwPolylineVertex(p84));
            poly8.Vertexes.Add(new LwPolylineVertex(p85));
            poly8.Vertexes.Add(new LwPolylineVertex(p82));
            poly8.Vertexes.Add(new LwPolylineVertex(p81));
            poly8.Vertexes.Add(new LwPolylineVertex(p80));
            poly8.Vertexes.Add(new LwPolylineVertex(p49));
            poly8.Vertexes.Add(new LwPolylineVertex(p80));
            poly8.Vertexes.Add(new LwPolylineVertex(p83));
            poly8.Vertexes.Add(new LwPolylineVertex(p84));
            poly8.Vertexes.Add(new LwPolylineVertex(p81));
            fun.PolyFill(dxf, poly8, 0.1, contour);

            Line line14 = new Line(p0, p86);
            line14.Lineweight = Lineweight.W25;//Lineweight指线宽
            line14.Layer = additionalline;//Layer指图层
            line14.Linetype = Linetype.DashDot;//Linetype指是点划线还是虚线什么的
            dxf.AddEntity(line14);
            Line line15 = new Line(p86, p87);
            line15.Lineweight = Lineweight.W25;//Lineweight指线宽              
            dxf.AddEntity(line15);
            Line line16 = new Line(p87, p88);
            line16.Lineweight = Lineweight.W25;//Lineweight指线宽               
            dxf.AddEntity(line16);

            Solid entity1 = new Solid(p89, p90, p91);
            dxf.AddEntity(entity1);



            Line line17 = new Line(p0, p92);
            line17.Lineweight = Lineweight.W25;//Lineweight指线宽
            line17.Layer = additionalline;//Layer指图层
            line17.Linetype = Linetype.DashDot;//Linetype指是点划线还是虚线什么的
            dxf.AddEntity(line17);
            Line line18 = new Line(p92, p93);
            line18.Lineweight = Lineweight.W25;//Lineweight指线宽              
            dxf.AddEntity(line18);
            Line line19 = new Line(p93, p94);
            line19.Lineweight = Lineweight.W25;//Lineweight指线宽               
            dxf.AddEntity(line19);
            Solid entity2 = new Solid(p95, p96, p97);
            dxf.AddEntity(entity2);

            //标注

            DimensionStyle dimensionStyle = new DimensionStyle("sd");
            dimensionStyle.ArrowSize = 1.6;
            dimensionStyle.DimArrow1 = DimensionArrowhead.Closedfilled;
            dimensionStyle.DimArrow2 = DimensionArrowhead.Closedfilled;
            dimensionStyle.TextHeight = 1.2;
            double offset = D;




            fun.dimrot1(dxf, p0, p37, 45, D - 2, 2, 1.6, 1.2, 0.9, "c=" + c, "", "");
            fun.dimrot1(dxf, p0, p34, -45, D - 2, 2, 1.6, 1.2, 0.9, "c=" + c, "", "");
            fun.dimrot1(dxf, p52, p54, 0, E * 2, 2, 1.6, 1.2, 0.9, "E=" + E, "", "");
            fun.dimrot1(dxf, p51, p64, 0, E, 2, 1.6, 1.2, 0.9, "E1=" + E1, "", "");
            fun.dimrot1(dxf, p55, p57, -90, E, 2, 1.6, 1.2, 0.9, "D1=" + D1, "", "");
            fun.dimrot1(dxf, p53, p59, -90, E * 2, 2, 1.6, 1.2, 0.9, "D=" + D, "", "");
            //  fun.dimrot1(dxf, p42, p63, 180, E, 2, 1.6, 1.2, 0.9, "a×45", "", "");
            // fun.dimrot1(dxf, p59, p58, 180, E, 2, 1.6, 1.2, 0.9, "a×45", "", "");
            LinearDimension dim2 = new LinearDimension(new Line(p42, p63), offset, 180, dimensionStyle);
            dim2.UserText = "a×45";
            dxf.AddEntity(dim2);
            LinearDimension dim3 = new LinearDimension(new Line(p59, p58), offset, 180, dimensionStyle);
            dim3.UserText = "a×45";
            dxf.AddEntity(dim3);

            fun.dimrot1(dxf, p62, p60, 180, D / 2.0, 2, 1.6, 1.2, 0.9, "b=" + b, "", "");
            fun.dimrot1(dxf, p42, p61, 180, D + 8, 2, 1.6, 1.2, 0.9, "0.5E", "", "");



            fun.jdbz2(dxf, new Line(p0, fun.Polar(p0, pi / 2, 0.1)), new Line(p0, fun.Polar(p0, pi / 2 + pi / 4, 0.1)), D, 1.6, 1.2, 0.9, "45" + "°", "0", "0");
            fun.jdbz2(dxf, new Line(p0, fun.Polar(p0, pi / 2 - pi / 4, 0.1)), new Line(p0, fun.Polar(p0, pi / 2, 0.1)), D, 1.6, 1.2, 0.9, "45" + "°", "0", "0");
            // fun.jdbz2(dxf, new Line(p30, p28), new Line(p30, p29), D, 1.6, 1.2, 0.9, "90" + "°", "0", "0");
            Angular2LineDimension dim4 = new Angular2LineDimension(new Line(p30, p28), new Line(p30, p29), offset, dimensionStyle);
            dim4.UserText = "90" + "°";
            dxf.AddEntity(dim4);


            double isframe = Convert.ToInt32(data["isframe"]);
            String isframe_chose = Convert.ToString(data["isframe_chose"]);
            double scale = Convert.ToDouble(data["scale"]); //放大系数
            if (isframe == 1)
            {
                if (isframe_chose.Equals("0"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA0X(dxf, new Vector2(p0.X - 1189 / 2.0, p0.Y + 841 / 2.0), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }

                if (isframe_chose.Equals("1"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA1X(dxf, new Vector2(p0.X - 841 / 2.0, p0.Y + 594 / 2.0), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }

                if (isframe_chose.Equals("2"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA2X(dxf, new Vector2(p0.X - 594 / 2.0, p0.Y + 420 / 2.0), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }

                if (isframe_chose.Equals("3"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA3X(dxf, new Vector2(p0.X - 420 / 2.0, p0.Y + 297 / 2.0), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }

                if (isframe_chose.Equals("4X"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA4X(dxf, new Vector2(p0.X - 297 / 2.0, p0.Y + 210 / 2.0 - offset * 2.26), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }

                if (isframe_chose.Equals("4Y"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA4Y(dxf, new Vector2(p0.X - 210 / 2.0, p0.Y + 297 / 2.0), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }
            }

            fun.SetLayer(dxf);
            fun.SetByLayer(dxf);

            dxf.DrawingVariables.AcadVer = DxfVersion.AutoCad2007;
            dxf.Save(path);
        }

        public static void threadedcircularplatethread60(Dictionary<string, Object> data)  //60°圆板牙
        {
            DxfDocument dxf = new DxfDocument();
            dxf.Layers["0"].Lineweight = Lineweight.W25;
            Layer contour = new Layer("contour");//轮廓层
            Layer dimensioning = new Layer("dimensioning");//尺寸层
            Layer refin = new Layer("refin");//基准线/内轮廓/虚线
            Layer center = new Layer("center");//中心线
            Layer textlayer = new Layer("textlayer");//文本层
            Layer hatching = new Layer("hatching");//填充层
            Layer additionalline = new Layer("additionalline");//附加线
            Layer cutting = new Layer("cutting");//切削层
            fun.SetLayer(dxf);
            double pi = Math.PI;
            string path = Convert.ToString(data["path"]);
            /*
            double d = 7.0;
            double P = 1.0;
            double d1 = d - (P * 1.0825);//小径
            double b = 5.0;
            double D = 30;
            double D1 = 24;
            double DD1 = 0;
            double E = 8.0;
            double E1 = 0;
            double c = 0.8;
            double a = 0.5;
            double pxk = 6;//排泄孔
            double px = pi - pi /4/4;
            */

            double d = Convert.ToDouble(data["td"]);
            double P = Convert.ToDouble(data["tp"]);
            double d1 = d - (P * 1.0825);//小径
            double b = Convert.ToDouble(data["b"]);
            double D = Convert.ToDouble(data["bd"]);
            double D1 = Convert.ToDouble(data["d1"]);
            double DD1 = Convert.ToDouble(data["dd1"]);
            double E = Convert.ToDouble(data["oal"]);
            double E1 = Convert.ToDouble(data["drvsc"]);
            double c = Convert.ToDouble(data["c"]);
            double a = Convert.ToDouble(data["a"]);
            double pxk = Convert.ToDouble(data["pxk"]);//排泄孔
            double px = pi - pi / 4 / 4;
            double pd = d % 1;
            double pd1 = (pd * 10.0) % 1;
            /*
            double d = 7.723;
            double P = 0.941;
            double d1 = d - (P * 1.0825);//小径
            double b = 5;
            double D = 30;
            double D1 = 0;
            double DD1 = 0;
            double E = 11;
            double E1 = 5.5;
            double c = 1;
            double a = 1;
            double pxk = 6;//排泄孔
            double px = pi - pi / 4 / 4;

            double pd = d % 1;
            double pd1 = (pd * 10.0) % 1;
            */
            if (pxk == 0)
            {
                pxk = DD1 / 2 - d1 / 2.0 + 0.01;

            }

            if (D >= 25 && pd1 != 0)
            {
                px = pi / 2 + pi / 4 / 4;

            }
            else
            {
                px = pi - pi / 4 / 4;
            }



            if (D >= 25 && pd1 != 0)
            {

                D1 = D - b;
                DD1 = D1;
            }



            double ang1 = Math.Acos(((d1 / 2.0 * d1 / 2.0) + ((d1 / 2 - 0.1 + pxk / 2.0) * (d1 / 2 - 0.1 + pxk / 2.0)) - (pxk / 2.0 * pxk / 2.0)) / (2 * d1 / 2.0 * (d1 / 2 - 0.1 + pxk / 2.0)));

            double ang2 = Math.Acos(((d / 2.0 * d / 2.0) + ((d1 / 2 - 0.1 + pxk / 2.0) * (d1 / 2 - 0.1 + pxk / 2.0)) - (pxk / 2.0 * pxk / 2.0)) / (2 * d / 2.0 * (d1 / 2 - 0.1 + pxk / 2.0)));



            Vector2 zx1 = new Vector2(0, D / 2 + 5);
            Vector2 zx2 = new Vector2(0, D / -2 - 5);
            Vector2 zx3 = new Vector2(D / 2 + 5, 0);
            Vector2 zx4 = new Vector2(D / -2 - 5, 0);


            Vector2 p0 = new Vector2(0, 0);
            Vector2 p1p = fun.Polar(p0, pi / 2, d1 / 2 - 0.1 + pxk / 2.0);
            Vector2 p2p = fun.PointRotate(p0, p1p, (pi * 2.0 / 5.0));
            Vector2 p3p = fun.PointRotate(p0, p1p, (pi * 2.0 / 5.0) * 2);
            Vector2 p4p = fun.PointRotate(p0, p1p, (pi * 2.0 / 5.0) * 3);
            Vector2 p5p = fun.PointRotate(p0, p1p, (pi * 2.0 / 5.0) * 4);
            Vector2 p6p = fun.PointRotate(p0, p1p, (pi * 2.0 / 5.0) * 5);

            Vector2 p1 = fun.Polar(p0, pi / 2 + ang1, d1 / 2.0);
            Vector2 p2 = fun.Polar(p0, pi / 2 + ang2, d / 2.0);
            Vector2 p3 = fun.Polar(p0, pi / 2 - ang1, d1 / 2.0);
            Vector2 p4 = fun.Polar(p0, pi / 2 - ang2, d / 2.0);

            Vector2 p5 = fun.PointRotate(p0, p1, (pi * 2.0 / 5.0));
            Vector2 p6 = fun.PointRotate(p0, p2, (pi * 2.0 / 5.0));
            Vector2 p7 = fun.PointRotate(p0, p3, (pi * 2.0 / 5.0));
            Vector2 p8 = fun.PointRotate(p0, p4, (pi * 2.0 / 5.0));

            Vector2 p9 = fun.PointRotate(p0, p1, (pi * 2.0 / 5.0) * 2);
            Vector2 p10 = fun.PointRotate(p0, p2, (pi * 2.0 / 5.0) * 2);
            Vector2 p11 = fun.PointRotate(p0, p3, (pi * 2.0 / 5.0) * 2);
            Vector2 p12 = fun.PointRotate(p0, p4, (pi * 2.0 / 5.0) * 2);

            Vector2 p13 = fun.PointRotate(p0, p1, (pi * 2.0 / 5.0) * 3);
            Vector2 p14 = fun.PointRotate(p0, p2, (pi * 2.0 / 5.0) * 3);
            Vector2 p15 = fun.PointRotate(p0, p3, (pi * 2.0 / 5.0) * 3);
            Vector2 p16 = fun.PointRotate(p0, p4, (pi * 2.0 / 5.0) * 3);

            Vector2 p17 = fun.PointRotate(p0, p1, (pi * 2.0 / 5.0) * 4);
            Vector2 p18 = fun.PointRotate(p0, p2, (pi * 2.0 / 5.0) * 4);
            Vector2 p19 = fun.PointRotate(p0, p3, (pi * 2.0 / 5.0) * 4);
            Vector2 p20 = fun.PointRotate(p0, p4, (pi * 2.0 / 5.0) * 4);
            //卡槽
            Vector2 p21 = fun.Polar(p0, pi / 2 + 5 * pi / 180, D / 2);
            Vector2 p22 = fun.Polar(p0, pi / 2 + 5 * pi / 180, D1 / 2);
            Vector2 p23 = fun.Polar(p0, pi / 2 + 5 * pi / 180, DD1 / 2);

            Vector2 p24 = fun.Polar(p0, pi / 2 - 5 * pi / 180, D / 2);
            Vector2 p24_ = fun.Polar(p0, pi / -2, D / 2);
            Vector2 p25 = fun.Polar(p0, pi / 2 - 5 * pi / 180, D1 / 2);
            Vector2 p26 = fun.Polar(p0, pi / 2 - 5 * pi / 180, DD1 / 2);
            Arc arc18 = fun.DrawArc(p21, p0, p24_);
            // dxf.AddEntity(arc10);
            fun.drawBArc(dxf, arc18, 0.1, contour);
            Arc arc19 = fun.DrawArc(p24_, p0, p24);
            // dxf.AddEntity(arc19);
            fun.drawBArc(dxf, arc19, 0.1, contour);

            //四个槽孔
            Vector2 p27 = fun.Polar(p0, pi / -4, Math.Sqrt(((D / 2) * (D / 2)) - (b / 2) * (b / 2)));
            Vector2 p28 = fun.Polar(p27, pi + pi / 4, b / 2);
            Vector2 p29 = fun.Polar(p27, pi / 4, b / 2);
            Vector2 p30 = fun.Polar(p27, pi / 2 + pi / 4, b / 2);
            Vector2 p31 = fun.PointRotate(p0, p30, (pi / 2));
            Vector2 p32_ = fun.Polar(p31, pi, 50);
            Vector2 p32 = fun.Inters1(p31, p32_, arc18, 2);
            Vector2 p33 = fun.Polar(p32, pi / -4, b);
            Vector2 p34_ = fun.PointRotate(p0, p30, (pi / -2));
            Vector2 p34 = fun.Polar(p34_, pi / -4, c);
            Vector2 p35_ = new Vector2(p34.X, p34.Y + 10);


            Vector2 p35 = fun.Inters1(p34, p35_, arc19, 1);
            Vector2 p36_ = fun.Polar(p34, 0, 50);
            Vector2 p36 = fun.Inters1(p34, p36_, arc19, 1);
            Vector2 p37 = fun.mirrorpoint(p34, zx1, zx2);
            Vector2 p38 = fun.mirrorpoint(p35, zx1, zx2);
            Vector2 p39 = fun.mirrorpoint(p36, zx1, zx2);

            Vector2 p40 = fun.Polar(p0, pi / -2, D / 2);
            Vector2 p41 = fun.Polar(p40, 0, D * 2);
            Vector2 p42 = fun.Polar(p41, pi / 2, a);
            Vector2 p43 = fun.Polar(p41, pi / 2, D / 2 - DD1 / 2);
            Vector2 p44 = fun.Polar(p43, pi / 2, DD1 / 4);
            Vector2 p45 = fun.Polar(p44, pi / 2, (d - d1) / 2.0);
            Vector2 p46 = fun.Polar(p43, pi / 2, DD1 / 2);
            Vector2 p47 = fun.Polar(p46, pi / 2, (DD1 / 2.0 / 3.0));
            Vector2 p48 = fun.Polar(p47, pi / 2, (d - d1) / 2.0);
            Vector2 p49 = fun.Polar(p47, pi / 2, (DD1 / 2.0 / 3.0));
            Vector2 p50 = fun.Polar(p49, pi / 2, (d - d1) / 2.0);
            Vector2 p51 = fun.Polar(p43, pi / 2, DD1);
            Vector2 p52 = fun.Polar(p41, pi / 2, D);
            Vector2 p53 = fun.Polar(p52, 0, E - a);
            Vector2 p54 = fun.Polar(p53, pi / -4, Math.Sqrt(2) * a);
            Vector2 p55 = fun.Polar(p54, pi / -2, (D / 2.0) - (D1 / 2.0) - a);
            Vector2 p56 = fun.Polar(p46, 0, E);
            Vector2 p57 = fun.Polar(p55, pi / -2, D1);
            Vector2 p58 = fun.Polar(p57, pi / -2, (D / 2.0) - (D1 / 2.0) - a);
            Vector2 p59 = fun.Polar(p58, pi / -2 + pi / -4, Math.Sqrt(2) * a);
            Vector2 p60 = fun.Polar(p59, pi, E1 - b / 2.0);
            Vector2 p61 = fun.Polar(p60, pi - pi / 4, b / (Math.Sqrt(2)));
            Vector2 p62 = fun.Polar(p61, pi + pi / 4, b / (Math.Sqrt(2)));
            Vector2 p63 = fun.Polar(p62, pi, E - E1 - b / 2.0 - a);
            Vector2 p64 = fun.Polar(p55, pi, E - E);
            Vector2 p65 = fun.Polar(p57, pi, E - E);
            Vector2 p66 = fun.Polar(p51, 0, E);
            Vector2 p67 = fun.Polar(p43, 0, E);

            Vector2 p68;
            Vector2 p69;
            Vector2 p70;
            Vector2 p71;
            Vector2 p72;
            Vector2 p73;
            Vector2 p74;
            Vector2 p75;
            Vector2 p76;
            Vector2 p77;
            Vector2 p78;
            Vector2 p79;
            Vector2 p80;
            Vector2 p81;
            Vector2 p82;
            Vector2 p83;
            Vector2 p84;



            p68 = fun.Polar(p44, pi / 4, Math.Sqrt(2) * (E / 10.0));
            p69 = fun.Polar(p68, 10 * pi / 180, (E - (E / 10.0)) / Math.Cos(10 * pi / 180));
            p70 = fun.Polar(p44, 0, E);
            p71 = fun.Polar(p68, pi / 2, (d - d1) / 2.0);
            p72 = fun.Polar(p69, pi / 2, (d - d1) / 2.0);
            p73 = fun.Polar(p45, 0, E);
            p74 = fun.Polar(p47, pi / -4, Math.Sqrt(2) * (E / 10.0));
            p75 = fun.Polar(p74, -10 * pi / 180, (E - (E / 10.0)) / Math.Cos(10 * pi / 180));
            p76 = fun.Polar(p47, 0, E);
            p77 = fun.Polar(p74, pi / 2, (d - d1) / 2.0);
            p78 = fun.Polar(p75, pi / 2, (d - d1) / 2.0);
            p79 = fun.Polar(p48, 0, E);
            p80 = fun.Polar(p49, pi / -4, Math.Sqrt(2) * (E / 10.0));
            p81 = fun.Polar(p80, -10 * pi / 180, (E - (E / 10.0)) / Math.Cos(10 * pi / 180));
            p82 = fun.Polar(p49, 0, E);
            p83 = fun.Polar(p80, pi / 2, (d - d1) / 2.0);
            p84 = fun.Polar(p81, pi / 2, (d - d1) / 2.0);





            Vector2 p85 = fun.Polar(p50, 0, E);
            //刨线
            Vector2 p86 = fun.Polar(p0, px, D / 2 + 4);
            Vector2 p87 = fun.Polar(p86, px, 4);
            Vector2 p88 = fun.Polar(p87, px - pi / 2, 4);
            Vector2 p89 = fun.Polar(p88, px, 1.2 * Math.Tan(10 * pi / 180));
            Vector2 p90 = fun.Polar(p88, px - pi, 1.2 * Math.Tan(10 * pi / 180));
            Vector2 p91 = fun.Polar(p88, px - pi / 2, 1.2);
            Vector2 p92 = fun.Polar(p0, pi / -4, D / 2 + 4);
            Vector2 p93 = fun.Polar(p92, pi / -4, 4);
            Vector2 p94 = fun.Polar(p93, pi / -4 + pi / 2, 4);
            Vector2 p95 = fun.Polar(p94, pi / -4 - pi, 1.2 * Math.Tan(10 * pi / 180));
            Vector2 p96 = fun.Polar(p94, pi / -4, 1.2 * Math.Tan(10 * pi / 180));
            Vector2 p97 = fun.Polar(p94, pi / -4 + pi / 2, 1.2);


            Vector2 zx5 = fun.Polar(p46, pi, 4);
            Vector2 zx6 = fun.Polar(p56, 0, 4);




            Line line3 = new Line(p28, p30);
            fun.drawBline(dxf, line3, 0.1, contour);
            Line line4 = new Line(p29, p30);
            fun.drawBline(dxf, line4, 0.1, contour);
            Line line5 = new Line(p32, p31);
            fun.drawBline(dxf, line5, 0.1, contour);
            Line line6 = new Line(p33, p31);
            fun.drawBline(dxf, line6, 0.1, contour);
            Line line7 = new Line(p34, p36);
            fun.drawBline(dxf, line7, 0.1, contour);
            Line line8 = new Line(p34, p35);
            fun.drawBline(dxf, line8, 0.1, contour);
            Line line9 = new Line(p37, p39);
            fun.drawBline(dxf, line9, 0.1, contour);
            Line line10 = new Line(p37, p38);
            fun.drawBline(dxf, line10, 0.1, contour);



            Arc arc1 = fun.DrawArc(p3, p1p, p1);
            fun.drawBArc(dxf, arc1, 0.1, contour);
            Arc arc2 = fun.DrawArc(p7, p2p, p5);
            fun.drawBArc(dxf, arc2, 0.1, contour);
            Arc arc3 = fun.DrawArc(p11, p3p, p9);
            fun.drawBArc(dxf, arc3, 0.1, contour);
            Arc arc4 = fun.DrawArc(p15, p4p, p13);
            fun.drawBArc(dxf, arc4, 0.1, contour);
            Arc arc5 = fun.DrawArc(p19, p5p, p17);
            fun.drawBArc(dxf, arc5, 0.1, contour);
            Arc arc6 = fun.DrawArc(p6, p0, p4);
            fun.drawBArc(dxf, arc6, 0.1, contour);
            Arc arc7 = fun.DrawArc(p5, p0, p3);
            fun.drawBArc(dxf, arc7, 0.1, contour);
            Arc arc8 = fun.DrawArc(p10, p0, p8);
            fun.drawBArc(dxf, arc8, 0.1, contour);
            Arc arc9 = fun.DrawArc(p9, p0, p7);
            fun.drawBArc(dxf, arc9, 0.1, contour);
            Arc arc10 = fun.DrawArc(p14, p0, p12);
            fun.drawBArc(dxf, arc10, 0.1, contour);
            Arc arc11 = fun.DrawArc(p13, p0, p11);
            fun.drawBArc(dxf, arc11, 0.1, contour);
            Arc arc12 = fun.DrawArc(p18, p0, p16);
            fun.drawBArc(dxf, arc12, 0.1, contour);
            Arc arc13 = fun.DrawArc(p17, p0, p15);
            fun.drawBArc(dxf, arc13, 0.1, contour);
            Arc arc14 = fun.DrawArc(p2, p0, p20);
            fun.drawBArc(dxf, arc14, 0.1, contour);
            Arc arc15 = fun.DrawArc(p1, p0, p19);
            fun.drawBArc(dxf, arc15, 0.1, contour);

            Arc arc16 = fun.DrawArc(p21, p0, p24);
            fun.drawBArc(dxf, arc16, 0.1, contour);
            Arc arc17 = fun.DrawArc(p25, p0, p22);
            fun.drawBArc(dxf, arc17, 0.1, contour);






            Circle circle1 = new Circle(new Vector3(0, 0, 0), DD1 / 2);
            //dxf.AddEntity(circle1);


            Line line1 = new Line(p21, p23);
            Line line2 = new Line(p24, p26);
            fun.drawBline(dxf, line1, 0.1, contour);
            fun.drawBline(dxf, line2, 0.1, contour);



            //中心线

            Line line11 = new Line(zx1, zx2);
            line11.Lineweight = Lineweight.W25;//Lineweight指线宽
            line11.Layer = center;//Layer指图层
            line11.Linetype = Linetype.DashDot;//Linetype指是点划线还是虚线什么的
            dxf.AddEntity(line11);

            Line line12 = new Line(zx3, zx4);
            line12.Lineweight = Lineweight.W25;//Lineweight指线宽
            line12.Layer = center;//Layer指图层
            line12.Linetype = Linetype.DashDot;//Linetype指是点划线还是虚线什么的
            dxf.AddEntity(line12);

            Line line13 = new Line(zx5, zx6);
            line13.Lineweight = Lineweight.W25;//Lineweight指线宽
            line13.Layer = center;//Layer指图层
            line13.Linetype = Linetype.DashDot;//Linetype指是点划线还是虚线什么的
            dxf.AddEntity(line13);

            /*
            Vector2 p13 = fun.Polar(p0, pi / 2 + 5 * pi / 180, D / 2);
            Vector2 p14 = fun.Polar(p0, pi / 2 - 5 * pi / 180, D / 2);
            Vector2 p15 = fun.Polar(p0, pi / 2 + 5 * pi / 180, D / 2);
            Vector2 p16 = fun.Polar(p0, pi / 2 - 5 * pi / 180, D / 2);

            Vector2 p17 = fun.Polar(p0, pi / 2 + 5 * pi / 180, D / 2);
            Vector2 p18 = fun.Polar(p0, pi / 2 - 5 * pi / 180, D / 2);
            Vector2 p18_ = fun.Polar(p0, pi / -2, D / 2);
            Vector2 p19 = fun.Polar(p0, pi / 2 + 5 * pi / 180, D1 / 2);
            Vector2 p20 = fun.Polar(p0, pi / 2 - 5 * pi / 180, D1 / 2);
            Arc arc10 = fun.DrawArc(p17, p0, p18);
            // dxf.AddEntity(arc10);
            fun.drawBArc(dxf, arc10, 0.1, contour);
            */


            if (D >= 25 && pd1 != 0)
            {
                LwPolyline poly1 = new LwPolyline();
                poly1.Vertexes.Add(new LwPolylineVertex(p42));
                poly1.Vertexes.Add(new LwPolylineVertex(fun.Polar(p52, pi / -2, a)));
                poly1.Vertexes.Add(new LwPolylineVertex(fun.Polar(p52, 0, a)));
                poly1.Vertexes.Add(new LwPolylineVertex(p53));
                poly1.Vertexes.Add(new LwPolylineVertex(p54));
                poly1.Vertexes.Add(new LwPolylineVertex(p58));
                poly1.Vertexes.Add(new LwPolylineVertex(p59));
                poly1.Vertexes.Add(new LwPolylineVertex(p60));
                poly1.Vertexes[7].Bulge = Math.Tan((105 * pi / 180) / 4);
                poly1.Vertexes.Add(new LwPolylineVertex(p62));
                poly1.Vertexes.Add(new LwPolylineVertex(p63));
                poly1.Vertexes.Add(new LwPolylineVertex(p42));
                fun.PolyFill(dxf, poly1, 0.1, contour);



                LwPolyline poly4 = new LwPolyline();
                poly4.Vertexes.Add(new LwPolylineVertex(p51));
                poly4.Vertexes.Add(new LwPolylineVertex(fun.Polar(p52, pi / -2, a)));
                poly4.Vertexes.Add(new LwPolylineVertex(fun.Polar(p52, 0, a)));
                poly4.Vertexes.Add(new LwPolylineVertex(p53));
                poly4.Vertexes.Add(new LwPolylineVertex(p54));
                poly4.Vertexes.Add(new LwPolylineVertex(p55));
                poly4.Vertexes.Add(new LwPolylineVertex(p64));
                poly4.Vertexes.Add(new LwPolylineVertex(p66));
                poly4.Vertexes.Add(new LwPolylineVertex(p51));
                poly4.IsClosed = true;
                fun.PolyFill(dxf, poly4, 0.1, contour);//将poly1这条线设置为宽度0.4的实体，contour轮廓实体。
                String[] htype1 = new String[100];
                Line[] hline1 = new Line[100];
                Arc[] harc1 = new Arc[100];
                int hnumst1 = poly4.Explode().Count;  //记录爆炸后，线段有多少
                for (int i = 0; i < hnumst1; i++)
                {
                    htype1[i] = poly4.Explode()[i].Type.ToString();    //将所有元素的类型记录成一个数组
                    if (htype1[i] == "Line")
                    {
                        hline1[i] = (Line)poly4.Explode()[i];
                    }
                    if (htype1[i] == "Arc")
                    {
                        harc1[i] = (Arc)poly4.Explode()[i];
                    }
                }
                fun.hatchsub1(dxf, htype1, hnumst1, 45, 1, hline1, harc1, hatching);
            }

            else
            {
                LwPolyline poly1 = new LwPolyline();
                poly1.Vertexes.Add(new LwPolylineVertex(p42));
                poly1.Vertexes.Add(new LwPolylineVertex(p52));
                poly1.Vertexes.Add(new LwPolylineVertex(p53));
                poly1.Vertexes[2].Bulge = -Math.Tan((pi / 2) / 4);
                poly1.Vertexes.Add(new LwPolylineVertex(p54));
                poly1.Vertexes.Add(new LwPolylineVertex(p58));
                poly1.Vertexes[4].Bulge = -Math.Tan((pi / 2) / 4);
                poly1.Vertexes.Add(new LwPolylineVertex(p59));
                poly1.Vertexes.Add(new LwPolylineVertex(p63));
                poly1.Vertexes[6].Bulge = -Math.Tan((pi / 2) / 4);
                poly1.Vertexes.Add(new LwPolylineVertex(p42));
                fun.PolyFill(dxf, poly1, 0.1, contour);


                LwPolyline poly4 = new LwPolyline();
                poly4.Vertexes.Add(new LwPolylineVertex(p51));
                poly4.Vertexes.Add(new LwPolylineVertex(p52));
                poly4.Vertexes.Add(new LwPolylineVertex(p53));
                poly4.Vertexes[2].Bulge = -Math.Tan((pi / 2) / 4);
                poly4.Vertexes.Add(new LwPolylineVertex(p54));
                poly4.Vertexes.Add(new LwPolylineVertex(p55));
                poly4.Vertexes.Add(new LwPolylineVertex(p64));
                poly4.Vertexes.Add(new LwPolylineVertex(p66));
                poly4.Vertexes.Add(new LwPolylineVertex(p51));
                poly4.IsClosed = true;
                fun.PolyFill(dxf, poly4, 0.1, contour);//将poly1这条线设置为宽度0.4的实体，contour轮廓实体。
                String[] htype1 = new String[100];
                Line[] hline1 = new Line[100];
                Arc[] harc1 = new Arc[100];
                int hnumst1 = poly4.Explode().Count;  //记录爆炸后，线段有多少
                for (int i = 0; i < hnumst1; i++)
                {
                    htype1[i] = poly4.Explode()[i].Type.ToString();    //将所有元素的类型记录成一个数组
                    if (htype1[i] == "Line")
                    {
                        hline1[i] = (Line)poly4.Explode()[i];
                    }
                    if (htype1[i] == "Arc")
                    {
                        harc1[i] = (Arc)poly4.Explode()[i];
                    }
                }
                fun.hatchsub1(dxf, htype1, hnumst1, 45, 1, hline1, harc1, hatching);
            }
            LwPolyline poly2 = new LwPolyline();
            poly2.Vertexes.Add(new LwPolylineVertex(p51));
            poly2.Vertexes.Add(new LwPolylineVertex(p43));
            poly2.Vertexes.Add(new LwPolylineVertex(p67));
            poly2.Vertexes.Add(new LwPolylineVertex(p66));
            poly2.Vertexes.Add(new LwPolylineVertex(p51));
            fun.PolyFill(dxf, poly2, 0.1, contour);


            LwPolyline poly3 = new LwPolyline();
            poly3.Vertexes.Add(new LwPolylineVertex(p55));
            poly3.Vertexes.Add(new LwPolylineVertex(p64));
            poly3.Vertexes.Add(new LwPolylineVertex(p65));
            poly3.Vertexes.Add(new LwPolylineVertex(p57));
            poly3.Vertexes.Add(new LwPolylineVertex(p55));
            fun.PolyFill(dxf, poly3, 0.1, contour);




            LwPolyline poly5 = new LwPolyline();
            poly5.Vertexes.Add(new LwPolylineVertex(p42));
            poly5.Vertexes.Add(new LwPolylineVertex(p43));
            poly5.Vertexes.Add(new LwPolylineVertex(p67));
            poly5.Vertexes.Add(new LwPolylineVertex(p65));
            poly5.Vertexes.Add(new LwPolylineVertex(p57));
            poly5.Vertexes.Add(new LwPolylineVertex(p58));

            poly5.Vertexes.Add(new LwPolylineVertex(p59));
            poly5.Vertexes.Add(new LwPolylineVertex(p60));
            poly5.Vertexes.Add(new LwPolylineVertex(p61));
            poly5.Vertexes.Add(new LwPolylineVertex(p62));
            poly5.Vertexes.Add(new LwPolylineVertex(p63));

            poly5.Vertexes.Add(new LwPolylineVertex(p42));
            poly5.IsClosed = true;
            fun.PolyFill(dxf, poly5, 0.1, contour);//将poly1这条线设置为宽度0.4的实体，contour轮廓实体。
            String[] htype2 = new String[100];
            Line[] hline2 = new Line[100];
            Arc[] harc2 = new Arc[100];
            int hnumst2 = poly5.Explode().Count;  //记录爆炸后，线段有多少
            for (int i = 0; i < hnumst2; i++)
            {
                htype2[i] = poly5.Explode()[i].Type.ToString();    //将所有元素的类型记录成一个数组
                if (htype2[i] == "Line")
                {
                    hline2[i] = (Line)poly5.Explode()[i];
                }
                if (htype2[i] == "Arc")
                {
                    harc2[i] = (Arc)poly5.Explode()[i];
                }
            }
            fun.hatchsub1(dxf, htype2, hnumst2, 45, 1, hline2, harc2, hatching);

            if (D >= 25 && pd1 != 0)
            {
            }
            else
            {


                poly5.Vertexes[5].Bulge = -Math.Tan((pi / 2) / 4);
                poly5.Vertexes[10].Bulge = -Math.Tan((pi / 2) / 4);
            }

            LwPolyline poly6 = new LwPolyline();
            poly6.Vertexes.Add(new LwPolylineVertex(p44));
            poly6.Vertexes.Add(new LwPolylineVertex(p45));
            poly6.Vertexes.Add(new LwPolylineVertex(p71));
            poly6.Vertexes.Add(new LwPolylineVertex(p72));
            poly6.Vertexes.Add(new LwPolylineVertex(p73));
            poly6.Vertexes.Add(new LwPolylineVertex(p70));
            poly6.Vertexes.Add(new LwPolylineVertex(p69));
            poly6.Vertexes.Add(new LwPolylineVertex(p68));
            poly6.Vertexes.Add(new LwPolylineVertex(p44));
            poly6.Vertexes.Add(new LwPolylineVertex(p68));
            poly6.Vertexes.Add(new LwPolylineVertex(p71));
            poly6.Vertexes.Add(new LwPolylineVertex(p72));
            poly6.Vertexes.Add(new LwPolylineVertex(p69));
            fun.PolyFill(dxf, poly6, 0.1, contour);



            if (D >= 25 && pd1 != 0)
            {
            }
            else
            {
                LwPolyline poly7 = new LwPolyline();
                poly7.Vertexes.Add(new LwPolylineVertex(p47));
                poly7.Vertexes.Add(new LwPolylineVertex(p48));
                poly7.Vertexes.Add(new LwPolylineVertex(p77));
                poly7.Vertexes.Add(new LwPolylineVertex(p78));
                poly7.Vertexes.Add(new LwPolylineVertex(p79));
                poly7.Vertexes.Add(new LwPolylineVertex(p76));
                poly7.Vertexes.Add(new LwPolylineVertex(p75));
                poly7.Vertexes.Add(new LwPolylineVertex(p74));
                poly7.Vertexes.Add(new LwPolylineVertex(p47));
                poly7.Vertexes.Add(new LwPolylineVertex(p74));
                poly7.Vertexes.Add(new LwPolylineVertex(p77));
                poly7.Vertexes.Add(new LwPolylineVertex(p78));
                poly7.Vertexes.Add(new LwPolylineVertex(p75));
                fun.PolyFill(dxf, poly7, 0.1, contour);
            }
            LwPolyline poly8 = new LwPolyline();
            poly8.Vertexes.Add(new LwPolylineVertex(p49));
            poly8.Vertexes.Add(new LwPolylineVertex(p50));
            poly8.Vertexes.Add(new LwPolylineVertex(p83));
            poly8.Vertexes.Add(new LwPolylineVertex(p84));
            poly8.Vertexes.Add(new LwPolylineVertex(p85));
            poly8.Vertexes.Add(new LwPolylineVertex(p82));
            poly8.Vertexes.Add(new LwPolylineVertex(p81));
            poly8.Vertexes.Add(new LwPolylineVertex(p80));
            poly8.Vertexes.Add(new LwPolylineVertex(p49));
            poly8.Vertexes.Add(new LwPolylineVertex(p80));
            poly8.Vertexes.Add(new LwPolylineVertex(p83));
            poly8.Vertexes.Add(new LwPolylineVertex(p84));
            poly8.Vertexes.Add(new LwPolylineVertex(p81));
            fun.PolyFill(dxf, poly8, 0.1, contour);

            Line line14 = new Line(p0, p86);
            line14.Lineweight = Lineweight.W25;//Lineweight指线宽
            line14.Layer = additionalline;//Layer指图层
            line14.Linetype = Linetype.DashDot;//Linetype指是点划线还是虚线什么的
            dxf.AddEntity(line14);
            Line line15 = new Line(p86, p87);
            line15.Lineweight = Lineweight.W25;//Lineweight指线宽              
            dxf.AddEntity(line15);
            Line line16 = new Line(p87, p88);
            line16.Lineweight = Lineweight.W25;//Lineweight指线宽               
            dxf.AddEntity(line16);

            Solid entity1 = new Solid(p89, p90, p91);
            dxf.AddEntity(entity1);



            Line line17 = new Line(p0, p92);
            line17.Lineweight = Lineweight.W25;//Lineweight指线宽
            line17.Layer = additionalline;//Layer指图层
            line17.Linetype = Linetype.DashDot;//Linetype指是点划线还是虚线什么的
            dxf.AddEntity(line17);
            Line line18 = new Line(p92, p93);
            line18.Lineweight = Lineweight.W25;//Lineweight指线宽              
            dxf.AddEntity(line18);
            Line line19 = new Line(p93, p94);
            line19.Lineweight = Lineweight.W25;//Lineweight指线宽               
            dxf.AddEntity(line19);
            Solid entity2 = new Solid(p95, p96, p97);
            dxf.AddEntity(entity2);

            //标注

            DimensionStyle dimensionStyle = new DimensionStyle("sd");
            dimensionStyle.ArrowSize = 1.6;
            dimensionStyle.DimArrow1 = DimensionArrowhead.Closedfilled;
            dimensionStyle.DimArrow2 = DimensionArrowhead.Closedfilled;
            dimensionStyle.TextHeight = 1.2;
            double offset = D + 6;




            fun.dimrot1(dxf, p0, p37, 45, D - 2, 2, 1.6, 1.2, 0.9, "c=" + c, "", "");
            fun.dimrot1(dxf, p0, p34, -45, D - 2, 2, 1.6, 1.2, 0.9, "c=" + c, "", "");
            fun.dimrot1(dxf, p52, p54, 0, E * 2, 2, 1.6, 1.2, 0.9, "E=" + E, "", "");
            fun.dimrot1(dxf, p61, p58, 180, E, 2, 1.6, 1.2, 0.9, "E1=" + E1, "", "");
            fun.dimrot1(dxf, p53, p59, -90, E * 2, 2, 1.6, 1.2, 0.9, "D=" + D, "", "");
            //  fun.dimrot1(dxf, p42, p63, 180, E, 2, 1.6, 1.2, 0.9, "a×45", "", "");
            // fun.dimrot1(dxf, p59, p58, 180, E, 2, 1.6, 1.2, 0.9, "a×45", "", "");
            LinearDimension dim2 = new LinearDimension(new Line(p42, p63), offset / 2.0, 180, dimensionStyle);
            dim2.UserText = "a×45";
            dxf.AddEntity(dim2);
            LinearDimension dim3 = new LinearDimension(new Line(p59, p58), offset / 2.0, 180, dimensionStyle);
            dim3.UserText = "a×45";
            dxf.AddEntity(dim3);
            fun.dimrot1(dxf, p37, p38, 45, (D + 2.0) / 4.0, 2, 1.6, 1.2, 0.9, "b=" + b, "", "");




            fun.jdbz2(dxf, new Line(p0, fun.Polar(p0, pi / 2, 0.1)), new Line(p0, fun.Polar(p0, pi / 2 + pi / 4, 0.1)), D, 1.6, 1.2, 0.9, "45" + "°", "0", "0");
            fun.jdbz2(dxf, new Line(p0, fun.Polar(p0, pi / 2 - pi / 4, 0.1)), new Line(p0, fun.Polar(p0, pi / 2, 0.1)), D, 1.6, 1.2, 0.9, "45" + "°", "0", "0");
            // fun.jdbz2(dxf, new Line(p30, p28), new Line(p30, p29), D, 1.6, 1.2, 0.9, "90" + "°", "0", "0");
            Angular2LineDimension dim4 = new Angular2LineDimension(new Line(p0, fun.Polar(p0, pi / 2 + pi / 4, 0.1)), new Line(p0, fun.Polar(p0, pi / 2 - pi / 4, 0.1)), offset, dimensionStyle);
            dim4.UserText = "90" + "°";
            dxf.AddEntity(dim4);


            Text txt = new Text("A", p87, 1.2, px * 180 / pi - 90);
            dxf.AddEntity(txt);

            Text txt1 = new Text("A", p93, 1.2, 45);
            dxf.AddEntity(txt1);

            Text txt2 = new Text("A-A", new Vector2(p46.X + ((p56.X - p46.X) / 2.0), p53.Y + 5), 1.2, 0);
            dxf.AddEntity(txt2);


            double isframe = Convert.ToInt32(data["isframe"]);
            String isframe_chose = Convert.ToString(data["isframe_chose"]);
            double scale = Convert.ToDouble(data["scale"]); //放大系数
            if (isframe == 1)
            {
                if (isframe_chose.Equals("0"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA0X(dxf, new Vector2(p0.X - 1189 / 2.0, p0.Y + 841 / 2.0), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }

                if (isframe_chose.Equals("1"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA1X(dxf, new Vector2(p0.X - 841 / 2.0, p0.Y + 594 / 2.0), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }

                if (isframe_chose.Equals("2"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA2X(dxf, new Vector2(p0.X - 594 / 2.0, p0.Y + 420 / 2.0), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }

                if (isframe_chose.Equals("3"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA3X(dxf, new Vector2(p0.X - 420 / 2.0, p0.Y + 297 / 2.0), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }

                if (isframe_chose.Equals("4X"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA4X(dxf, new Vector2(p0.X - 297 / 2.0, p0.Y + 210 / 2.0 - offset * 2.26), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }

                if (isframe_chose.Equals("4Y"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA4Y(dxf, new Vector2(p0.X - 210 / 2.0, p0.Y + 297 / 2.0), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }
            }




            fun.SetLayer(dxf);
            fun.SetByLayer(dxf);

            dxf.DrawingVariables.AcadVer = DxfVersion.AutoCad2007;
            dxf.Save(path);
        }

        public static void ISYC_301_05(Dictionary<string, Object> data)  //3圆板牙
        {

            DxfDocument dxf = new DxfDocument();
            dxf.Layers["0"].Lineweight = Lineweight.W25;
            Layer contour = new Layer("contour");//轮廓层
            Layer dimensioning = new Layer("dimensioning");//尺寸层
            Layer refin = new Layer("refin");//基准线/内轮廓/虚线
            Layer center = new Layer("center");//中心线
            Layer textlayer = new Layer("textlayer");//文本层
            Layer hatching = new Layer("hatching");//填充层
            Layer additionalline = new Layer("additionalline");//附加线
            Layer cutting = new Layer("cutting");//切削层
            fun.SetLayer(dxf);

            double pi = Math.PI;
            /*
                double oal = Convert.ToDouble(data["oal"]);
                double bd = Convert.ToDouble(data["bd"]);
                double td = Convert.ToDouble(data["td"]);
                double tdn = Convert.ToDouble(data["tdn"]);
                double tdz = Convert.ToDouble(data["tdz"]);
                double ddch = Convert.ToDouble(data["ddch"]);
                double ddchc = Convert.ToDouble(data["ddchc"]);
                //double dchc = Convert.ToDouble(data["dchc"]);
                string path = Convert.ToString(data["path"]);
            */



            double oal = 12;
            double bd = 30;
            double td = 7;
            double tdn = 6;
            double tdz = 8;
            double ddch = 10;
            double ddchc = 15;
            double DIM = 1;
            //double dchc = Convert.ToDouble(data["dchc"]);
            string path = Convert.ToString(data["path"]);




            DimensionStyle dimensionStyle = fun.CreateDimStyle();
            dimensionStyle.ArrowSize = 0.8;
            dimensionStyle.DimArrow1 = DimensionArrowhead.Closedfilled;
            dimensionStyle.DimArrow2 = DimensionArrowhead.Closedfilled;
            dimensionStyle.TextHeight = 0.6;
            double offset = 7;
            Vector2 p00 = new Vector2(0, 0);
            Vector2 p01 = fun.Polar(p00, pi / 2, bd);
            Vector2 p02 = fun.Polar(p00, pi / 2, bd / 2);
            Vector2 p1 = fun.Polar(p02, pi * 1.5 + pi / 3.0 - Math.Acos((ddchc * ddchc + tdn * tdn - ddch * ddch) / (2.0 * ddchc * tdn)), tdn / 2);
            Vector2 p2 = fun.Polar(p02, pi * 1.5 - pi / 3.0 + Math.Acos((ddchc * ddchc + tdn * tdn - ddch * ddch) / (2.0 * ddchc * tdn)), tdn / 2);
            Vector2 p3 = fun.Polar(p02, pi * 1.5 - pi / 3.0 - Math.Acos((ddchc * ddchc + tdn * tdn - ddch * ddch) / (2.0 * ddchc * tdn)), tdn / 2);
            Vector2 p4 = fun.Polar(p02, pi * 0.5 + Math.Acos((ddchc * ddchc + tdn * tdn - ddch * ddch) / (2.0 * ddchc * tdn)), tdn / 2);
            //Console.WriteLine(Math.Acos((ddchc * ddchc + tdn * tdn - ddch * ddch) / (2.0 * ddchc * tdn)) * 180 / pi);
            //Console.ReadKey();
            Vector2 p5 = fun.Polar(p02, pi * 0.5 - Math.Acos((ddchc * ddchc + tdn * tdn - ddch * ddch) / (2.0 * ddchc * tdn)), tdn / 2);
            Vector2 p6 = fun.Polar(p02, pi * 1.5 + pi / 3.0 + Math.Acos((ddchc * ddchc + tdn * tdn - ddch * ddch) / (2.0 * ddchc * tdn)), tdn / 2);
            Vector2 p13 = fun.Polar(p02, pi / 3 + 1.5 * pi, ddchc / 2);
            Vector2 p14 = fun.Polar(p02, pi / 6 + pi, ddchc / 2);
            Vector2 p15 = fun.Polar(p02, pi / 2, ddchc / 2);
            Vector2 p133 = fun.Polar(p02, pi / 3 + 1.5 * pi, tdz / 2);
            Vector2 p144 = fun.Polar(p02, pi / 6 + pi, tdz / 2);
            Vector2 p155 = fun.Polar(p02, pi / 2, tdz / 2);
            Arc arc1 = fun.DrawArc(p1, p13, p6);
            Arc arc2 = fun.DrawArc(p3, p14, p2);
            Arc arc3 = fun.DrawArc(p5, p15, p4);
            Arc arc4 = fun.DrawArc(p144, p02, p133);
            Arc arc5 = fun.DrawArc(p155, p02, p144);
            Arc arc6 = fun.DrawArc(p133, p02, p155);
            Vector2 p7 = fun.getPointofcir(p13, p1, p6, p02, p144, p133);
            Vector2 p8 = new Vector2(-p7.X, p7.Y);
            Vector2 p9 = fun.getPointofcir(p14, p3, p2, p02, p155, p144);
            Vector2 p10 = fun.getPointofcir(p02, p155, p144, p15, p5, p4);
            Vector2 p11 = new Vector2(-p10.X, p10.Y);
            Vector2 p12 = new Vector2(-p9.X, p9.Y);
            Vector2 p16 = fun.Polar(p02, pi / 6, bd * 0.9 / 2);
            Vector2 p17 = fun.Polar(p02, 1.5 * pi, bd * 0.9 / 2);
            Vector2 p18 = fun.Polar(p02, pi / 3 + pi * 0.5, bd * 0.9 / 2);
            Arc arc7 = fun.DrawArc(p00, p02, p01);
            Vector2 p19 = fun.getPointForArcandLine(p18, fun.Polar(p18, pi / 6 + pi / 2, 100), p02, arc7);
            Vector2 p23 = fun.getPointForArcandLine(p17, fun.Polar(p17, 1.5 * pi - pi / 6, 100), p02, arc7);
            Vector2 p24 = fun.getPointForArcandLine(p18, fun.Polar(p18, pi, 100), p02, arc7);
            Vector2 p20 = new Vector2(-p19.X, p19.Y);
            Vector2 p21 = new Vector2(-p24.X, p24.Y);
            Vector2 p22 = new Vector2(-p23.X, p23.Y);

            Vector2 p25 = new Vector2(p02.X - bd, p01.Y);
            Vector2 p26 = new Vector2(p25.X, p00.Y);
            Vector2 p27 = new Vector2(p26.X - oal, p26.Y);
            Vector2 p28 = new Vector2(p27.X, p25.Y);
            //坐标点
            Vector2 p29 = new Vector2(p25.X, p25.Y / 2.0);
            Vector2 p30 = new Vector2(p27.X, p28.Y / 2.0);
            //下面的坐标点
            Vector2 p31 = fun.Polar(p02, pi / -2, offset * 5);
            // Vector2 p32 = fun.Polar(p27, pi / -2, offset * 1.5);
            Vector2 p32 = new Vector2(p27.X, p31.Y);
            Vector2 p33;
            Vector2 p34;
            Vector2 p35;
            Vector2 p36;
            Vector2 p37;
            Vector2 p38;
            Vector2 p39;
            Vector2 p40;
            Vector2 p41;
            Vector2 p42;
            Vector2 p43;



            p33 = fun.Polar(p30, pi + pi / 4, 2 * 0.5);
            p34 = fun.Polar(p30, pi + pi / 6, 2 * 0.5 * 8);
            p35 = fun.Polar(p29, pi / 4, 2 * 0.5);
            p36 = fun.Polar(p29, pi / 4, 2 * 0.5 * 4);
            p37 = fun.Polar(fun.Polar(p02, 0, tdz / 2), pi / -6, 2);
            p38 = fun.Polar(p37, pi / -6, bd / 2.0);
            p39 = fun.Polar(p38, pi / -6, 0.2);
            p40 = fun.Polar(p02, pi - pi / 4, offset * 4.5);
            p41 = fun.Polar(p31, 0, bd / 2.0 + oal + 0.1);
            p42 = fun.Polar(p31, 0, bd / 2.0 + 0.1);
            p43 = fun.Polar(p31, 0, bd / 2.0);



            /*
           Arc arc10= fun.DrawArc(p6, p02, p5);
            arc10.Linetype = Linetype.ByLayer;
            dxf.AddEntity(arc10);*/

            LwPolyline poly1 = new LwPolyline();
            poly1.Vertexes.Add(new LwPolylineVertex(p6));
            poly1.Vertexes[0].Bulge = Math.Tan((2 * pi / 3 - Math.Acos((ddchc * ddchc + ddch * ddch - tdn * tdn) / (2.0 * ddchc * ddch)) * 2) / 4);
            poly1.Vertexes.Add(new LwPolylineVertex(p5));
            poly1.Vertexes[1].Bulge = Math.Tan((pi * 2 - Math.Acos((ddchc * ddchc + ddch * ddch - tdn * tdn) / (2.0 * ddchc * ddch)) * 2) / 4);
            //Console.WriteLine(Math.Acos((ddchc / 2 - tdn / 2) / (ddch / 2)) * 180 / pi);
            //Console.ReadKey();
            poly1.Vertexes.Add(new LwPolylineVertex(p4));
            poly1.Vertexes[2].Bulge = Math.Tan((2 * pi / 3 - Math.Acos((ddchc * ddchc + ddch * ddch - tdn * tdn) / (2.0 * ddchc * ddch)) * 2) / 4);
            poly1.Vertexes.Add(new LwPolylineVertex(p3));
            poly1.Vertexes[3].Bulge = Math.Tan((pi * 2 - Math.Acos((ddchc * ddchc + ddch * ddch - tdn * tdn) / (2.0 * ddchc * ddch)) * 2) / 4);
            poly1.Vertexes.Add(new LwPolylineVertex(p2));
            poly1.Vertexes[4].Bulge = Math.Tan((2 * pi / 3 - Math.Acos((ddchc * ddchc + ddch * ddch - tdn * tdn) / (2.0 * ddchc * ddch)) * 2) / 4);
            poly1.Vertexes.Add(new LwPolylineVertex(p1));
            poly1.Vertexes[5].Bulge = Math.Tan((pi * 2 - Math.Acos((ddchc * ddchc + ddch * ddch - tdn * tdn) / (2.0 * ddchc * ddch)) * 2) / 4);
            poly1.Vertexes.Add(new LwPolylineVertex(p6));
            fun.PolyFill(dxf, poly1, 0.3, contour);

            LwPolyline poly2 = new LwPolyline();
            poly2.Vertexes.Add(new LwPolylineVertex(p7));
            poly2.Vertexes[0].Bulge = Math.Tan(-(2 * pi / 3 - Math.Acos((ddchc * ddchc + ddch * ddch - tdn * tdn) / (2.0 * ddchc * ddch)) * 2) / 5);
            poly2.Vertexes.Add(new LwPolylineVertex(p8));
            fun.PolyFill(dxf, poly2, 0.3, contour);

            LwPolyline poly3 = new LwPolyline();
            poly3.Vertexes.Add(new LwPolylineVertex(p9));
            poly3.Vertexes[0].Bulge = Math.Tan(-(2 * pi / 3 - Math.Acos((ddchc * ddchc + ddch * ddch - tdn * tdn) / (2.0 * ddchc * ddch)) * 2) / 5);
            poly3.Vertexes.Add(new LwPolylineVertex(p10));
            fun.PolyFill(dxf, poly3, 0.3, contour);

            LwPolyline poly4 = new LwPolyline();
            poly4.Vertexes.Add(new LwPolylineVertex(p11));
            poly4.Vertexes[0].Bulge = Math.Tan(-(2 * pi / 3 - Math.Acos((ddchc * ddchc + ddch * ddch - tdn * tdn) / (2.0 * ddchc * ddch)) * 2) / 5);
            poly4.Vertexes.Add(new LwPolylineVertex(p12));
            fun.PolyFill(dxf, poly4, 0.3, contour);

            fun.drawcircle(dxf, p02, 0.9 * bd / 2, 0.3, contour);
            fun.drawcircle(dxf, p02, bd / 2, 0.3, contour);

            LwPolyline poly5 = new LwPolyline();
            poly5.Vertexes.Add(new LwPolylineVertex(p15));
            poly5.Vertexes[0].Bulge = Math.Tan(-pi / 3);
            poly5.Vertexes.Add(new LwPolylineVertex(p14));
            fun.PolyFillandlinetype(dxf, poly5, 0.1, refin, Linetype.Dashed);

            LwPolyline poly6 = new LwPolyline();
            poly6.Vertexes.Add(new LwPolylineVertex(p15));
            poly6.Vertexes[0].Bulge = Math.Tan(pi / 6);
            poly6.Vertexes.Add(new LwPolylineVertex(p14));
            fun.PolyFillandlinetype(dxf, poly6, 0.1, refin, Linetype.Dashed);

            LwPolyline poly7 = new LwPolyline();
            poly7.Vertexes.Add(new LwPolylineVertex(p25));
            poly7.Vertexes.Add(new LwPolylineVertex(p26));
            poly7.Vertexes.Add(new LwPolylineVertex(p27));
            poly7.Vertexes.Add(new LwPolylineVertex(p28));
            poly7.Vertexes.Add(new LwPolylineVertex(p25));
            fun.PolyFill(dxf, poly7, 0.3, contour);
            /*
            Vector2[] xuline1 = { p18, p19 };
            fun.drawPlinetype(dxf, xuline1, 0.15, refin, Linetype.Dashed);
            Vector2[] xuline2 = { p24, p18 };
            fun.drawPlinetype(dxf, xuline2, 0.15, refin, Linetype.Dashed);

            Vector2[] xuline3 = { p17, p22 };
            fun.drawPlinetype(dxf, xuline3, 0.15, refin, Linetype.Dashed);

            Vector2[] xuline4 = { p17, p23 };
            fun.drawPlinetype(dxf, xuline4, 0.15, refin, Linetype.Dashed);
            Vector2[] xuline5 = { p20, p16 };
            fun.drawPlinetype(dxf, xuline5, 0.15, refin, Linetype.Dashed);
            Vector2[] xuline6 = { p21, p16 };
            fun.drawPlinetype(dxf, xuline6, 0.15, refin, Linetype.Dashed);
            */

            Vector2[] cenline1 = { fun.Polar(p01, pi * 0.5, 4), fun.Polar(p00, 1.5 * pi, 4) };
            fun.drawPlinetype(dxf, cenline1, 0.15, center, Linetype.Center);
            Vector2[] cenline2 = { p02, fun.Polar(p02, pi + pi / 6, 0.4 * bd) };

            fun.drawPlinetype(dxf, cenline2, 0.15, center, Linetype.Center);
            Vector2[] cenline3 = { p02, fun.Polar(p02, 1.5 * pi + pi / 3, 0.4 * bd) };
            fun.drawPlinetype(dxf, cenline3, 0.15, center, Linetype.Center);
            /*
            Vector2[] cenline4 = { p18, fun.Polar(p18, 0.5 * pi + pi / 3, 0.1 * bd) };
            fun.drawPlinetype(dxf, cenline4, 0.15, centre, Linetype.Center);
            Vector2[] cenline5 = { p16, fun.Polar(p16, pi / 6, 0.1 * bd) };
            fun.drawPlinetype(dxf, cenline5, 0.15, centre, Linetype.Center);
            */


            LinearDimension linedim1 = new LinearDimension(new Line(p27, p26), offset * 1, 180, dimensionStyle);
            linedim1.UserText = "OAL ";
            dxf.AddEntity(linedim1);
            LinearDimension linedim2 = new LinearDimension(new Line(fun.Polar(p02, pi, bd / 2), fun.Polar(p02, 0, bd / 2)), offset * 4.5, 180, dimensionStyle);
            linedim2.UserText = "BD";
            dxf.AddEntity(linedim2);
            LinearDimension linedim7 = new LinearDimension(new Line(fun.Polar(p02, 0.5 * pi, td / 2), fun.Polar(p02, 1.5 * pi, td / 2)), offset * 3, 270, dimensionStyle);
            fun.dxflinedim(dxf, linedim7, "TD");

            double isframe = Convert.ToInt32(data["isframe"]);
            String isframe_chose = Convert.ToString(data["isframe_chose"]);
            double scale = Convert.ToDouble(data["scale"]); //放大系数
            Vector2 p0 = new Vector2(0, 0);
            if (isframe == 1)
            {
                if (isframe_chose.Equals("0"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA0X(dxf, new Vector2(p0.X - 1189 / 2.0, p0.Y + 841 / 2.0), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }

                if (isframe_chose.Equals("1"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA1X(dxf, new Vector2(p0.X - 841 / 2.0, p0.Y + 594 / 2.0), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }

                if (isframe_chose.Equals("2"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA2X(dxf, new Vector2(p0.X - 594 / 2.0, p0.Y + 420 / 2.0), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }

                if (isframe_chose.Equals("3"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA3X(dxf, new Vector2(p0.X - 420 / 2.0, p0.Y + 297 / 2.0), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }

                if (isframe_chose.Equals("4X"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA4X(dxf, new Vector2(p0.X - 297 / 2.0, p0.Y + 210 / 2.0 - 10 * 2.26), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }

                if (isframe_chose.Equals("4Y"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA4Y(dxf, new Vector2(p0.X - 210 / 2.0, p0.Y + 297 / 2.0), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }
            }



            fun.SetLayer(dxf);
            fun.SetByLayer(dxf);
            dxf.DrawingVariables.AcadVer = DxfVersion.AutoCad2007;
            dxf.Save(path);
        }
        public static void ISYC_301_06(Dictionary<string, Object> data)  //6角板牙       
        {
            DxfDocument dxf = new DxfDocument();
            dxf.Layers["0"].Lineweight = Lineweight.W25;
            Layer contour = new Layer("contour");//轮廓层
            Layer dimensioning = new Layer("dimensioning");//尺寸层
            Layer refin = new Layer("refin");//基准线/内轮廓/虚线
            Layer center = new Layer("center");//中心线
            Layer textlayer = new Layer("textlayer");//文本层
            Layer hatching = new Layer("hatching");//填充层
            Layer additionalline = new Layer("additionalline");//附加线
            Layer cutting = new Layer("cutting");//切削层
            fun.SetLayer(dxf);

            double pi = Math.PI;

            double oal = Convert.ToDouble(data["oal"]);
            double td = Convert.ToDouble(data["td"]);
            double drvs = Convert.ToDouble(data["drvs"]);
            double tp = Convert.ToDouble(data["tp"]);
            string path = Convert.ToString(data["path"]);


            double le = drvs * 0.5 / Math.Sin(pi / 3);
            double td1 = td - 1.0825 * tp;
            double d1 = td / 2.2;

            /*
            double oal = 12;
            double td = 6;
            double drvs = 24;
            double tp = 1;
            string path = Convert.ToString(data["path"]);
            double DIM = 0;
            double le = drvs * 0.5 / Math.Sin(pi / 3);
            double td1 = td - 1.0825 * tp;
            double d1 = td / 2.2;
            */
            Vector2 p0 = new Vector2(0, 0);
            Vector2 p1 = fun.Polar(p0, pi, le);
            Vector2 p2 = fun.Polar(p0, 4.0 / 3 * pi, le);
            Vector2 p3 = fun.Polar(p0, 5.0 / 3 * pi, le);
            Vector2 p4 = fun.Polar(p0, 0, le);
            Vector2 p5 = fun.Polar(p0, 1.0 / 3 * pi, le);
            Vector2 p6 = fun.Polar(p0, 2.0 / 3 * pi, le);

            LwPolyline poly1 = new LwPolyline();
            poly1.Vertexes.Add(new LwPolylineVertex(p1));
            poly1.Vertexes.Add(new LwPolylineVertex(p2));
            poly1.Vertexes.Add(new LwPolylineVertex(p3));
            poly1.Vertexes.Add(new LwPolylineVertex(p4));
            poly1.Vertexes.Add(new LwPolylineVertex(p5));
            poly1.Vertexes.Add(new LwPolylineVertex(p6));
            poly1.Vertexes.Add(new LwPolylineVertex(p1));
            fun.PolyFill(dxf, poly1, 0.3, contour);

            double ang1 = Math.Asin(d1 * 0.5 / td1);

            Vector2 p11 = fun.Polar(p0, pi - ang1, td1);
            Vector2 p12 = fun.Polar(p11, pi, 1.0825 * tp);
            Vector2 p13 = fun.Polar(p12, pi, 1.5 * tp);
            Vector2 p34 = new Vector2(p0.X - p11.X, p11.Y);
            Vector2 p33 = new Vector2(p0.X - p12.X, p12.Y);
            Vector2 p32 = new Vector2(p0.X - p13.X, p13.Y);
            Vector2 p14 = new Vector2(p13.X, p0.Y - p13.Y);
            Vector2 p15 = new Vector2(p12.X, p0.Y - p12.Y);
            Vector2 p16 = new Vector2(p11.X, p0.Y - p11.Y);
            Vector2 p29 = new Vector2(p34.X, p0.Y - p34.Y);
            Vector2 p30 = new Vector2(p33.X, p0.Y - p33.Y);
            Vector2 p31 = new Vector2(p32.X, p0.Y - p32.Y);

            Vector2 p41 = fun.Polar(p0, pi - ang1 - pi / 3, td1);
            Vector2 p42 = fun.Polar(p41, 2.0 / 3 * pi, 1.0825 * tp);
            Vector2 p43 = fun.Polar(p42, 2.0 / 3 * pi, 1.5 * tp);
            Vector2 p44 = fun.Polar(p43, 7.0 / 6 * pi, d1);
            Vector2 p45 = fun.Polar(p42, 7.0 / 6 * pi, d1);
            Vector2 p46 = fun.Polar(p41, 7.0 / 6 * pi, d1);
            Vector2 p35 = new Vector2(p0.X - p46.X, p46.Y);
            Vector2 p36 = new Vector2(p0.X - p45.X, p45.Y);
            Vector2 p37 = new Vector2(p0.X - p44.X, p44.Y);
            Vector2 p38 = new Vector2(p0.X - p43.X, p43.Y);
            Vector2 p39 = new Vector2(p0.X - p42.X, p42.Y);
            Vector2 p40 = new Vector2(p0.X - p41.X, p41.Y);

            Vector2 p17 = new Vector2(p46.X, p0.Y - p46.Y);
            Vector2 p18 = new Vector2(p45.X, p0.Y - p45.Y);
            Vector2 p19 = new Vector2(p44.X, p0.Y - p44.Y);
            Vector2 p20 = new Vector2(p43.X, p0.Y - p43.Y);
            Vector2 p21 = new Vector2(p42.X, p0.Y - p42.Y);
            Vector2 p22 = new Vector2(p41.X, p0.Y - p41.Y);
            Vector2 p23 = new Vector2(p40.X, p0.Y - p40.Y);
            Vector2 p24 = new Vector2(p39.X, p0.Y - p39.Y);
            Vector2 p25 = new Vector2(p38.X, p0.Y - p38.Y);
            Vector2 p26 = new Vector2(p37.X, p0.Y - p37.Y);
            Vector2 p27 = new Vector2(p36.X, p0.Y - p36.Y);
            Vector2 p28 = new Vector2(p35.X, p0.Y - p35.Y);

            LwPolyline poly2 = new LwPolyline();
            poly2.Vertexes.Add(new LwPolylineVertex(p11));
            poly2.Vertexes.Add(new LwPolylineVertex(p13));
            poly2.Vertexes[1].Bulge = 1;
            poly2.Vertexes.Add(new LwPolylineVertex(p14));
            poly2.Vertexes.Add(new LwPolylineVertex(p16));
            poly2.Vertexes[3].Bulge = Math.Tan((pi / 3 - ang1 * 2) / 4);
            poly2.Vertexes.Add(new LwPolylineVertex(p17));
            poly2.Vertexes.Add(new LwPolylineVertex(p19));
            poly2.Vertexes[5].Bulge = 1;
            poly2.Vertexes.Add(new LwPolylineVertex(p20));
            poly2.Vertexes.Add(new LwPolylineVertex(p22));
            poly2.Vertexes[7].Bulge = Math.Tan((pi / 3 - ang1 * 2) / 4);
            poly2.Vertexes.Add(new LwPolylineVertex(p23));
            poly2.Vertexes.Add(new LwPolylineVertex(p25));
            poly2.Vertexes[9].Bulge = 1;
            poly2.Vertexes.Add(new LwPolylineVertex(p26));
            poly2.Vertexes.Add(new LwPolylineVertex(p28));
            poly2.Vertexes[11].Bulge = Math.Tan((pi / 3 - ang1 * 2) / 4);
            poly2.Vertexes.Add(new LwPolylineVertex(p29));
            poly2.Vertexes.Add(new LwPolylineVertex(p31));
            poly2.Vertexes[13].Bulge = 1;
            poly2.Vertexes.Add(new LwPolylineVertex(p32));
            poly2.Vertexes.Add(new LwPolylineVertex(p34));
            poly2.Vertexes[15].Bulge = Math.Tan((pi / 3 - ang1 * 2) / 4);
            poly2.Vertexes.Add(new LwPolylineVertex(p35));
            poly2.Vertexes.Add(new LwPolylineVertex(p37));
            poly2.Vertexes[17].Bulge = 1;
            poly2.Vertexes.Add(new LwPolylineVertex(p38));
            poly2.Vertexes.Add(new LwPolylineVertex(p40));
            poly2.Vertexes[19].Bulge = Math.Tan((pi / 3 - ang1 * 2) / 4);
            poly2.Vertexes.Add(new LwPolylineVertex(p41));
            poly2.Vertexes.Add(new LwPolylineVertex(p43));
            poly2.Vertexes[21].Bulge = 1;
            poly2.Vertexes.Add(new LwPolylineVertex(p44));
            poly2.Vertexes.Add(new LwPolylineVertex(p46));
            poly2.Vertexes[23].Bulge = Math.Tan((pi / 3 - ang1 * 2) / 4);
            poly2.Vertexes.Add(new LwPolylineVertex(p11));
            fun.PolyFill(dxf, poly2, 0.3, contour);

            Arc arc1 = fun.DrawArc(p45, p0, p12);
            arc1.Layer = contour;
            dxf.AddEntity(arc1);
            Arc arc2 = fun.DrawArc(p15, p0, p18);
            arc2.Layer = contour;
            dxf.AddEntity(arc2);
            Arc arc3 = fun.DrawArc(p21, p0, p24);
            arc3.Layer = contour;
            dxf.AddEntity(arc3);
            Arc arc4 = fun.DrawArc(p27, p0, p30);
            arc4.Layer = contour;
            dxf.AddEntity(arc4);
            Arc arc5 = fun.DrawArc(p33, p0, p36);
            arc5.Layer = contour;
            dxf.AddEntity(arc5);
            Arc arc6 = fun.DrawArc(p39, p0, p42);
            arc6.Layer = contour;
            dxf.AddEntity(arc6);

            Vector2 po1 = new Vector2(p4.X + drvs, p5.Y);
            Vector2 po2 = new Vector2(po1.X, p3.Y);
            Vector2 p1_ = new Vector2(po1.X, p1.Y);
            Vector2 p2_ = fun.Polar(p1_, 0, oal);
            Vector2 po3 = fun.Polar(po2, 0, oal);
            Vector2 po4 = new Vector2(po3.X, po1.Y);

            Line line1_ = new Line(p1_, p2_);
            fun.drawBline(dxf, line1_, 0.3, contour);


            LwPolyline poly3 = new LwPolyline();
            poly3.Vertexes.Add(new LwPolylineVertex(po1));
            poly3.Vertexes.Add(new LwPolylineVertex(po2));
            poly3.Vertexes.Add(new LwPolylineVertex(po3));
            poly3.Vertexes.Add(new LwPolylineVertex(po4));
            poly3.Vertexes.Add(new LwPolylineVertex(po1));
            fun.PolyFill(dxf, poly3, 0.3, contour);

            Vector2[] cenline1 = { fun.Polar(p1, pi, 1), fun.Polar(p4, 0, 1) };
            fun.drawPlinetype(dxf, cenline1, 0.15, center, Linetype.Center);
            Vector2[] cenline2 = { new Vector2(po1.X - 1, p0.Y), new Vector2(po4.X + 1, p0.Y) };
            fun.drawPlinetype(dxf, cenline2, 0.15, center, Linetype.Center);
            DimensionStyle dimensionStyle = fun.CreateDimStyle();
            dimensionStyle.ArrowSize = 0.2;
            dimensionStyle.DimArrow1 = DimensionArrowhead.Closedfilled;
            dimensionStyle.DimArrow2 = DimensionArrowhead.Closedfilled;
            dimensionStyle.TextHeight = 0.5;
            double offset = 7;






            Vector2 p50 = fun.Polar(po3, pi, (p3.X - p2.X) / 2.0);
            Vector2 p51 = fun.Polar(po3, pi / -2, drvs);
            Vector2 p52 = new Vector2(po1.X, p0.Y);
            Vector2 p53 = new Vector2(po4.X, p0.Y);
            Vector2 p54 = fun.Polar(p53, pi / 4, 0.1);
            Vector2 p55 = fun.Polar(p54, pi / 4, oal / 4.0);
            Vector2 p56 = fun.Polar(p55, pi / 2, 0.1);
            Vector2 p57 = fun.Polar(p52, pi + pi / 6, oal);
            Vector2 p58 = fun.Polar(p57, pi / -2, 0.1);
            Vector2 p59 = fun.Polar(p0, pi - pi / 6, drvs);
            Vector2 p60 = fun.Polar(p59, pi / 2, 0.5);
            Vector2 p61 = fun.Polar(p0, 0, td / 2.0);
            Vector2 p62 = fun.Polar(p61, pi / 6, drvs / 2.0 + 4);
            Vector2 p63 = fun.Polar(p62, pi / 2, 0.3);

            Vector2 p64 = fun.Polar(p0, pi / 4, td);
            Vector2 p65 = fun.Polar(p64, pi / 4, td);
            Vector2 p66 = fun.Polar(p65, pi / 4, 3);
            Vector2 p67 = new Vector2(po3.X + oal + 5, p51.Y);
            Vector2 p68 = new Vector2(po3.X + oal + 2.5, p51.Y);
            Vector2 p69 = new Vector2(po3.X + 5, p51.Y);

            LinearDimension linedim2 = new LinearDimension(new Line(po1, po4), offset, 0, dimensionStyle);
            linedim2.UserText = "OAL ";
            dxf.AddEntity(linedim2);



            LinearDimension linedim1 = new LinearDimension(new Line(p4, p6), offset * 3, 330, dimensionStyle);
            linedim1.UserText = "DRVS  ";
            dxf.AddEntity(linedim1);

            Vector2 p1_1 = fun.Polar(p0, pi / 2, td);
            Vector2 p2_1 = fun.Polar(p0, pi / -2, td);

            LinearDimension linedim3 = new LinearDimension(new Line(p1_1, p2_1), offset * 3, 90, dimensionStyle);
            linedim3.UserText = "TD  ";
            dxf.AddEntity(linedim3);

            double isframe = Convert.ToInt32(data["isframe"]);
            String isframe_chose = Convert.ToString(data["isframe_chose"]);
            double scale = Convert.ToDouble(data["scale"]); //放大系数

            if (isframe == 1)
            {
                if (isframe_chose.Equals("0"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA0X(dxf, new Vector2(p0.X - 1189 / 2.0, p0.Y + 841 / 2.0), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }

                if (isframe_chose.Equals("1"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA1X(dxf, new Vector2(p0.X - 841 / 2.0, p0.Y + 594 / 2.0), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }

                if (isframe_chose.Equals("2"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA2X(dxf, new Vector2(p0.X - 594 / 2.0, p0.Y + 420 / 2.0), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }

                if (isframe_chose.Equals("3"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA3X(dxf, new Vector2(p0.X - 420 / 2.0, p0.Y + 297 / 2.0), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }

                if (isframe_chose.Equals("4X"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA4X(dxf, new Vector2(p0.X - 297 / 2.0, p0.Y + 210 / 2.0 - 10 * 2.26), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }

                if (isframe_chose.Equals("4Y"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA4Y(dxf, new Vector2(p0.X - 210 / 2.0, p0.Y + 297 / 2.0), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }
            }



            fun.SetLayer(dxf);
            fun.SetByLayer(dxf);

            dxf.DrawingVariables.AcadVer = DxfVersion.AutoCad2007;
            dxf.Save(path);
        }
    }

}




